diff options
Diffstat (limited to 'tests/feed/FeedBuilderTest.php')
-rw-r--r-- | tests/feed/FeedBuilderTest.php | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/tests/feed/FeedBuilderTest.php b/tests/feed/FeedBuilderTest.php index fe37d5f2..c29e8ef3 100644 --- a/tests/feed/FeedBuilderTest.php +++ b/tests/feed/FeedBuilderTest.php | |||
@@ -10,13 +10,14 @@ use Shaarli\Bookmark\LinkDB; | |||
10 | use Shaarli\Config\ConfigManager; | 10 | use Shaarli\Config\ConfigManager; |
11 | use Shaarli\Formatter\FormatterFactory; | 11 | use Shaarli\Formatter\FormatterFactory; |
12 | use Shaarli\History; | 12 | use Shaarli\History; |
13 | use Shaarli\TestCase; | ||
13 | 14 | ||
14 | /** | 15 | /** |
15 | * FeedBuilderTest class. | 16 | * FeedBuilderTest class. |
16 | * | 17 | * |
17 | * Unit tests for FeedBuilder. | 18 | * Unit tests for FeedBuilder. |
18 | */ | 19 | */ |
19 | class FeedBuilderTest extends \PHPUnit\Framework\TestCase | 20 | class FeedBuilderTest extends TestCase |
20 | { | 21 | { |
21 | /** | 22 | /** |
22 | * @var string locale Basque (Spain). | 23 | * @var string locale Basque (Spain). |
@@ -44,7 +45,7 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
44 | /** | 45 | /** |
45 | * Called before every test method. | 46 | * Called before every test method. |
46 | */ | 47 | */ |
47 | public static function setUpBeforeClass() | 48 | public static function setUpBeforeClass(): void |
48 | { | 49 | { |
49 | $conf = new ConfigManager('tests/utils/config/configJson'); | 50 | $conf = new ConfigManager('tests/utils/config/configJson'); |
50 | $conf->set('resource.datastore', self::$testDatastore); | 51 | $conf->set('resource.datastore', self::$testDatastore); |
@@ -60,7 +61,7 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
60 | 'SERVER_NAME' => 'host.tld', | 61 | 'SERVER_NAME' => 'host.tld', |
61 | 'SERVER_PORT' => '80', | 62 | 'SERVER_PORT' => '80', |
62 | 'SCRIPT_NAME' => '/index.php', | 63 | 'SCRIPT_NAME' => '/index.php', |
63 | 'REQUEST_URI' => '/index.php?do=feed', | 64 | 'REQUEST_URI' => '/feed/atom', |
64 | ); | 65 | ); |
65 | } | 66 | } |
66 | 67 | ||
@@ -81,7 +82,7 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
81 | $this->assertEquals(self::$RSS_LANGUAGE, $data['language']); | 82 | $this->assertEquals(self::$RSS_LANGUAGE, $data['language']); |
82 | $this->assertRegExp('/Wed, 03 Aug 2016 09:30:33 \+\d{4}/', $data['last_update']); | 83 | $this->assertRegExp('/Wed, 03 Aug 2016 09:30:33 \+\d{4}/', $data['last_update']); |
83 | $this->assertEquals(true, $data['show_dates']); | 84 | $this->assertEquals(true, $data['show_dates']); |
84 | $this->assertEquals('http://host.tld/index.php?do=feed', $data['self_link']); | 85 | $this->assertEquals('http://host.tld/feed/atom', $data['self_link']); |
85 | $this->assertEquals('http://host.tld/', $data['index_url']); | 86 | $this->assertEquals('http://host.tld/', $data['index_url']); |
86 | $this->assertFalse($data['usepermalinks']); | 87 | $this->assertFalse($data['usepermalinks']); |
87 | $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); | 88 | $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); |
@@ -96,9 +97,9 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
96 | $pub = DateTime::createFromFormat(DateTime::RSS, $link['pub_iso_date']); | 97 | $pub = DateTime::createFromFormat(DateTime::RSS, $link['pub_iso_date']); |
97 | $up = DateTime::createFromFormat(DateTime::ATOM, $link['up_iso_date']); | 98 | $up = DateTime::createFromFormat(DateTime::ATOM, $link['up_iso_date']); |
98 | $this->assertEquals($pub, $up); | 99 | $this->assertEquals($pub, $up); |
99 | $this->assertContains('Stallman has a beard', $link['description']); | 100 | $this->assertContainsPolyfill('Stallman has a beard', $link['description']); |
100 | $this->assertContains('Permalink', $link['description']); | 101 | $this->assertContainsPolyfill('Permalink', $link['description']); |
101 | $this->assertContains('http://host.tld/shaare/WDWyig', $link['description']); | 102 | $this->assertContainsPolyfill('http://host.tld/shaare/WDWyig', $link['description']); |
102 | $this->assertEquals(1, count($link['taglist'])); | 103 | $this->assertEquals(1, count($link['taglist'])); |
103 | $this->assertEquals('sTuff', $link['taglist'][0]); | 104 | $this->assertEquals('sTuff', $link['taglist'][0]); |
104 | 105 | ||
@@ -200,16 +201,16 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
200 | $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); | 201 | $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); |
201 | $this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']); | 202 | $this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']); |
202 | $this->assertEquals('http://host.tld/shaare/WDWyig', $link['url']); | 203 | $this->assertEquals('http://host.tld/shaare/WDWyig', $link['url']); |
203 | $this->assertContains('Direct link', $link['description']); | 204 | $this->assertContainsPolyfill('Direct link', $link['description']); |
204 | $this->assertContains('http://host.tld/shaare/WDWyig', $link['description']); | 205 | $this->assertContainsPolyfill('http://host.tld/shaare/WDWyig', $link['description']); |
205 | // Second link is a direct link | 206 | // Second link is a direct link |
206 | $link = $data['links'][array_keys($data['links'])[1]]; | 207 | $link = $data['links'][array_keys($data['links'])[1]]; |
207 | $this->assertEquals(8, $link['id']); | 208 | $this->assertEquals(8, $link['id']); |
208 | $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114633'), $link['created']); | 209 | $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114633'), $link['created']); |
209 | $this->assertEquals('http://host.tld/shaare/RttfEw', $link['guid']); | 210 | $this->assertEquals('http://host.tld/shaare/RttfEw', $link['guid']); |
210 | $this->assertEquals('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['url']); | 211 | $this->assertEquals('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['url']); |
211 | $this->assertContains('Direct link', $link['description']); | 212 | $this->assertContainsPolyfill('Direct link', $link['description']); |
212 | $this->assertContains('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['description']); | 213 | $this->assertContainsPolyfill('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['description']); |
213 | } | 214 | } |
214 | 215 | ||
215 | /** | 216 | /** |
@@ -253,7 +254,7 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
253 | 'SERVER_NAME' => 'host.tld', | 254 | 'SERVER_NAME' => 'host.tld', |
254 | 'SERVER_PORT' => '8080', | 255 | 'SERVER_PORT' => '8080', |
255 | 'SCRIPT_NAME' => '/~user/shaarli/index.php', | 256 | 'SCRIPT_NAME' => '/~user/shaarli/index.php', |
256 | 'REQUEST_URI' => '/~user/shaarli/index.php?do=feed', | 257 | 'REQUEST_URI' => '/~user/shaarli/feed/atom', |
257 | ); | 258 | ); |
258 | $feedBuilder = new FeedBuilder( | 259 | $feedBuilder = new FeedBuilder( |
259 | self::$bookmarkService, | 260 | self::$bookmarkService, |
@@ -265,7 +266,7 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
265 | $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null); | 266 | $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null); |
266 | 267 | ||
267 | $this->assertEquals( | 268 | $this->assertEquals( |
268 | 'http://host.tld:8080/~user/shaarli/index.php?do=feed', | 269 | 'http://host.tld:8080/~user/shaarli/feed/atom', |
269 | $data['self_link'] | 270 | $data['self_link'] |
270 | ); | 271 | ); |
271 | 272 | ||
@@ -273,6 +274,6 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
273 | $link = $data['links'][array_keys($data['links'])[0]]; | 274 | $link = $data['links'][array_keys($data['links'])[0]]; |
274 | $this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['guid']); | 275 | $this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['guid']); |
275 | $this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['url']); | 276 | $this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['url']); |
276 | $this->assertContains('http://host.tld:8080/~user/shaarli/./add-tag/hashtag', $link['description']); | 277 | $this->assertContainsPolyfill('http://host.tld:8080/~user/shaarli/./add-tag/hashtag', $link['description']); |
277 | } | 278 | } |
278 | } | 279 | } |