From 03340c18ead651ef9e11f883745695f2edafbae3 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 12 May 2020 12:44:48 +0200 Subject: Slim router: handle add tag route --- tests/feed/FeedBuilderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/feed/FeedBuilderTest.php') diff --git a/tests/feed/FeedBuilderTest.php b/tests/feed/FeedBuilderTest.php index 54671891..535207aa 100644 --- a/tests/feed/FeedBuilderTest.php +++ b/tests/feed/FeedBuilderTest.php @@ -306,6 +306,6 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase $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']); + $this->assertContains('http://host.tld:8080/~user/shaarli/./add-tag/hashtag', $link['description']); } } -- cgit v1.2.3 From f4929b1188b4bc5e92b925ebc44f5ad40bb1a4ed Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Mon, 18 May 2020 13:03:13 +0200 Subject: Make FeedBuilder instance creation independant of the request stack --- tests/feed/FeedBuilderTest.php | 63 ++++++++++-------------------------------- 1 file changed, 15 insertions(+), 48 deletions(-) (limited to 'tests/feed/FeedBuilderTest.php') diff --git a/tests/feed/FeedBuilderTest.php b/tests/feed/FeedBuilderTest.php index 535207aa..b2b70b70 100644 --- a/tests/feed/FeedBuilderTest.php +++ b/tests/feed/FeedBuilderTest.php @@ -64,23 +64,6 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase ); } - /** - * Test GetTypeLanguage(). - */ - public function testGetTypeLanguage() - { - $feedBuilder = new FeedBuilder(null, self::$formatter, FeedBuilder::$FEED_ATOM, null, null, false); - $feedBuilder->setLocale(self::$LOCALE); - $this->assertEquals(self::$ATOM_LANGUAGUE, $feedBuilder->getTypeLanguage()); - $feedBuilder = new FeedBuilder(null, self::$formatter, FeedBuilder::$FEED_RSS, null, null, false); - $feedBuilder->setLocale(self::$LOCALE); - $this->assertEquals(self::$RSS_LANGUAGE, $feedBuilder->getTypeLanguage()); - $feedBuilder = new FeedBuilder(null, self::$formatter, FeedBuilder::$FEED_ATOM, null, null, false); - $this->assertEquals('en', $feedBuilder->getTypeLanguage()); - $feedBuilder = new FeedBuilder(null, self::$formatter, FeedBuilder::$FEED_RSS, null, null, false); - $this->assertEquals('en-en', $feedBuilder->getTypeLanguage()); - } - /** * Test buildData with RSS feed. */ @@ -89,13 +72,11 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase $feedBuilder = new FeedBuilder( self::$bookmarkService, self::$formatter, - FeedBuilder::$FEED_RSS, - self::$serverInfo, - null, + static::$serverInfo, false ); $feedBuilder->setLocale(self::$LOCALE); - $data = $feedBuilder->buildData(); + $data = $feedBuilder->buildData(FeedBuilder::$FEED_RSS, null); // Test headers (RSS) $this->assertEquals(self::$RSS_LANGUAGE, $data['language']); $this->assertRegExp('/Wed, 03 Aug 2016 09:30:33 \+\d{4}/', $data['last_update']); @@ -140,13 +121,11 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase $feedBuilder = new FeedBuilder( self::$bookmarkService, self::$formatter, - FeedBuilder::$FEED_ATOM, - self::$serverInfo, - null, + static::$serverInfo, false ); $feedBuilder->setLocale(self::$LOCALE); - $data = $feedBuilder->buildData(); + $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null); $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); $this->assertRegExp('/2016-08-03T09:30:33\+\d{2}:\d{2}/', $data['last_update']); $link = $data['links'][array_keys($data['links'])[2]]; @@ -166,13 +145,11 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase $feedBuilder = new FeedBuilder( self::$bookmarkService, self::$formatter, - FeedBuilder::$FEED_ATOM, - self::$serverInfo, - $criteria, + static::$serverInfo, false ); $feedBuilder->setLocale(self::$LOCALE); - $data = $feedBuilder->buildData(); + $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, $criteria); $this->assertEquals(1, count($data['links'])); $link = array_shift($data['links']); $this->assertEquals(41, $link['id']); @@ -190,13 +167,11 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase $feedBuilder = new FeedBuilder( self::$bookmarkService, self::$formatter, - FeedBuilder::$FEED_ATOM, - self::$serverInfo, - $criteria, + static::$serverInfo, false ); $feedBuilder->setLocale(self::$LOCALE); - $data = $feedBuilder->buildData(); + $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, $criteria); $this->assertEquals(3, count($data['links'])); $link = $data['links'][array_keys($data['links'])[2]]; $this->assertEquals(41, $link['id']); @@ -211,14 +186,12 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase $feedBuilder = new FeedBuilder( self::$bookmarkService, self::$formatter, - FeedBuilder::$FEED_ATOM, - self::$serverInfo, - null, + static::$serverInfo, false ); $feedBuilder->setLocale(self::$LOCALE); $feedBuilder->setUsePermalinks(true); - $data = $feedBuilder->buildData(); + $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null); $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); $this->assertTrue($data['usepermalinks']); // First link is a permalink @@ -247,14 +220,12 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase $feedBuilder = new FeedBuilder( self::$bookmarkService, self::$formatter, - FeedBuilder::$FEED_ATOM, - self::$serverInfo, - null, + static::$serverInfo, false ); $feedBuilder->setLocale(self::$LOCALE); $feedBuilder->setHideDates(true); - $data = $feedBuilder->buildData(); + $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null); $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); $this->assertFalse($data['show_dates']); @@ -262,14 +233,12 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase $feedBuilder = new FeedBuilder( self::$bookmarkService, self::$formatter, - FeedBuilder::$FEED_ATOM, - self::$serverInfo, - null, + static::$serverInfo, true ); $feedBuilder->setLocale(self::$LOCALE); $feedBuilder->setHideDates(true); - $data = $feedBuilder->buildData(); + $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null); $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); $this->assertTrue($data['show_dates']); } @@ -289,13 +258,11 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase $feedBuilder = new FeedBuilder( self::$bookmarkService, self::$formatter, - FeedBuilder::$FEED_ATOM, $serverInfo, - null, false ); $feedBuilder->setLocale(self::$LOCALE); - $data = $feedBuilder->buildData(); + $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null); $this->assertEquals( 'http://host.tld:8080/~user/shaarli/index.php?do=feed', -- cgit v1.2.3 From f7f08ceec1b218e1525153e8bd3d0199f2fb1c9d Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 28 Jul 2020 22:24:41 +0200 Subject: Fix basePath in unit tests reference DB --- tests/feed/FeedBuilderTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests/feed/FeedBuilderTest.php') diff --git a/tests/feed/FeedBuilderTest.php b/tests/feed/FeedBuilderTest.php index b2b70b70..5c2aaedb 100644 --- a/tests/feed/FeedBuilderTest.php +++ b/tests/feed/FeedBuilderTest.php @@ -90,15 +90,15 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase $link = $data['links'][array_keys($data['links'])[2]]; $this->assertEquals(41, $link['id']); $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); - $this->assertEquals('http://host.tld/?WDWyig', $link['guid']); - $this->assertEquals('http://host.tld/?WDWyig', $link['url']); + $this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']); + $this->assertEquals('http://host.tld/shaare/WDWyig', $link['url']); $this->assertRegExp('/Tue, 10 Mar 2015 11:46:51 \+\d{4}/', $link['pub_iso_date']); $pub = DateTime::createFromFormat(DateTime::RSS, $link['pub_iso_date']); $up = DateTime::createFromFormat(DateTime::ATOM, $link['up_iso_date']); $this->assertEquals($pub, $up); $this->assertContains('Stallman has a beard', $link['description']); $this->assertContains('Permalink', $link['description']); - $this->assertContains('http://host.tld/?WDWyig', $link['description']); + $this->assertContains('http://host.tld/shaare/WDWyig', $link['description']); $this->assertEquals(1, count($link['taglist'])); $this->assertEquals('sTuff', $link['taglist'][0]); @@ -198,15 +198,15 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase $link = $data['links'][array_keys($data['links'])[2]]; $this->assertEquals(41, $link['id']); $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); - $this->assertEquals('http://host.tld/?WDWyig', $link['guid']); - $this->assertEquals('http://host.tld/?WDWyig', $link['url']); + $this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']); + $this->assertEquals('http://host.tld/shaare/WDWyig', $link['url']); $this->assertContains('Direct link', $link['description']); - $this->assertContains('http://host.tld/?WDWyig', $link['description']); + $this->assertContains('http://host.tld/shaare/WDWyig', $link['description']); // Second link is a direct link $link = $data['links'][array_keys($data['links'])[3]]; $this->assertEquals(8, $link['id']); $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114633'), $link['created']); - $this->assertEquals('http://host.tld/?RttfEw', $link['guid']); + $this->assertEquals('http://host.tld/shaare/RttfEw', $link['guid']); $this->assertEquals('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['url']); $this->assertContains('Direct link', $link['description']); $this->assertContains('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['description']); @@ -271,8 +271,8 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase // Test first link (note link) $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->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['guid']); + $this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['url']); $this->assertContains('http://host.tld:8080/~user/shaarli/./add-tag/hashtag', $link['description']); } } -- cgit v1.2.3