X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FFeedBuilderTest.php;h=4ca58e5a3b514bf20f21a4597c3d49fb927c1378;hb=9d9f6d75b94aab51067bdfbe50b58b66d1194f6d;hp=ea1dde25cd09674775b4f5f2effcdb8a0d8f8e33;hpb=c3dfd8995921083ff7250c25d0b6ab1184b91aff;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/FeedBuilderTest.php b/tests/FeedBuilderTest.php index ea1dde25..4ca58e5a 100644 --- a/tests/FeedBuilderTest.php +++ b/tests/FeedBuilderTest.php @@ -75,7 +75,6 @@ class FeedBuilderTest extends PHPUnit_Framework_TestCase $data = $feedBuilder->buildData(); // Test headers (RSS) $this->assertEquals(self::$RSS_LANGUAGE, $data['language']); - $this->assertEmpty($data['pubsubhub_url']); $this->assertRegExp('/Wed, 03 Aug 2016 09:30:33 \+\d{4}/', $data['last_update']); $this->assertEquals(true, $data['show_dates']); $this->assertEquals('http://host.tld/index.php?do=feed', $data['self_link']); @@ -83,10 +82,10 @@ class FeedBuilderTest extends PHPUnit_Framework_TestCase $this->assertFalse($data['usepermalinks']); $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); - // Test first link (note link) - $link = reset($data['links']); + // Test first not pinned link (note link) + $link = $data['links'][array_keys($data['links'])[2]]; $this->assertEquals(41, $link['id']); - $this->assertEquals(DateTime::createFromFormat('Ymd_His', '20150310_114651'), $link['created']); + $this->assertEquals(DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); $this->assertEquals('http://host.tld/?WDWyig', $link['guid']); $this->assertEquals('http://host.tld/?WDWyig', $link['url']); $this->assertRegExp('/Tue, 10 Mar 2015 11:46:51 \+\d{4}/', $link['pub_iso_date']); @@ -120,7 +119,7 @@ class FeedBuilderTest extends PHPUnit_Framework_TestCase $data = $feedBuilder->buildData(); $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); $this->assertRegExp('/2016-08-03T09:30:33\+\d{2}:\d{2}/', $data['last_update']); - $link = reset($data['links']); + $link = $data['links'][array_keys($data['links'])[2]]; $this->assertRegExp('/2015-03-10T11:46:51\+\d{2}:\d{2}/', $link['pub_iso_date']); $this->assertRegExp('/2016-08-03T09:30:33\+\d{2}:\d{2}/', $data['links'][8]['up_iso_date']); } @@ -140,7 +139,7 @@ class FeedBuilderTest extends PHPUnit_Framework_TestCase $this->assertEquals(1, count($data['links'])); $link = array_shift($data['links']); $this->assertEquals(41, $link['id']); - $this->assertEquals(DateTime::createFromFormat('Ymd_His', '20150310_114651'), $link['created']); + $this->assertEquals(DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); } /** @@ -149,15 +148,15 @@ class FeedBuilderTest extends PHPUnit_Framework_TestCase public function testBuildDataCount() { $criteria = array( - 'nb' => '1', + 'nb' => '3', ); $feedBuilder = new FeedBuilder(self::$linkDB, FeedBuilder::$FEED_ATOM, self::$serverInfo, $criteria, false); $feedBuilder->setLocale(self::$LOCALE); $data = $feedBuilder->buildData(); - $this->assertEquals(1, count($data['links'])); - $link = array_shift($data['links']); + $this->assertEquals(3, count($data['links'])); + $link = $data['links'][array_keys($data['links'])[2]]; $this->assertEquals(41, $link['id']); - $this->assertEquals(DateTime::createFromFormat('Ymd_His', '20150310_114651'), $link['created']); + $this->assertEquals(DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); } /** @@ -172,17 +171,17 @@ class FeedBuilderTest extends PHPUnit_Framework_TestCase $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); $this->assertTrue($data['usepermalinks']); // First link is a permalink - $link = array_shift($data['links']); + $link = $data['links'][array_keys($data['links'])[2]]; $this->assertEquals(41, $link['id']); - $this->assertEquals(DateTime::createFromFormat('Ymd_His', '20150310_114651'), $link['created']); + $this->assertEquals(DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); $this->assertEquals('http://host.tld/?WDWyig', $link['guid']); $this->assertEquals('http://host.tld/?WDWyig', $link['url']); $this->assertContains('Direct link', $link['description']); $this->assertContains('http://host.tld/?WDWyig', $link['description']); // Second link is a direct link - $link = array_shift($data['links']); + $link = $data['links'][array_keys($data['links'])[3]]; $this->assertEquals(8, $link['id']); - $this->assertEquals(DateTime::createFromFormat('Ymd_His', '20150310_114633'), $link['created']); + $this->assertEquals(DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150310_114633'), $link['created']); $this->assertEquals('http://host.tld/?RttfEw', $link['guid']); $this->assertEquals('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['url']); $this->assertContains('Direct link', $link['description']); @@ -210,19 +209,6 @@ class FeedBuilderTest extends PHPUnit_Framework_TestCase $this->assertTrue($data['show_dates']); } - /** - * Test buildData with hide dates settings. - */ - public function testBuildDataPubsubhub() - { - $feedBuilder = new FeedBuilder(self::$linkDB, FeedBuilder::$FEED_ATOM, self::$serverInfo, null, false); - $feedBuilder->setLocale(self::$LOCALE); - $feedBuilder->setPubsubhubUrl('http://pubsubhub.io'); - $data = $feedBuilder->buildData(); - $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); - $this->assertEquals('http://pubsubhub.io', $data['pubsubhub_url']); - } - /** * Test buildData when Shaarli is served from a subdirectory */ @@ -251,7 +237,7 @@ class FeedBuilderTest extends PHPUnit_Framework_TestCase ); // Test first link (note link) - $link = array_shift($data['links']); + $link = $data['links'][array_keys($data['links'])[2]]; $this->assertEquals('http://host.tld:8080/~user/shaarli/?WDWyig', $link['guid']); $this->assertEquals('http://host.tld:8080/~user/shaarli/?WDWyig', $link['url']); $this->assertContains('http://host.tld:8080/~user/shaarli/?addtag=hashtag', $link['description']);