diff options
Diffstat (limited to 'tests')
16 files changed, 420 insertions, 50 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php index 35de47f9..f58d1c12 100644 --- a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php | |||
@@ -28,7 +28,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase | |||
28 | $this->assertSame(200, $client->getResponse()->getStatusCode()); | 28 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
29 | 29 | ||
30 | $newNbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); | 30 | $newNbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); |
31 | $this->assertGreaterThan(count($nbClients), count($newNbClients)); | 31 | $this->assertGreaterThan(\count($nbClients), \count($newNbClients)); |
32 | 32 | ||
33 | $this->assertGreaterThan(1, $alert = $crawler->filter('.settings ul li strong')->extract(['_text'])); | 33 | $this->assertGreaterThan(1, $alert = $crawler->filter('.settings ul li strong')->extract(['_text'])); |
34 | $this->assertContains('My app', $alert[0]); | 34 | $this->assertContains('My app', $alert[0]); |
@@ -65,7 +65,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase | |||
65 | 65 | ||
66 | $crawler = $client->request('GET', '/developer'); | 66 | $crawler = $client->request('GET', '/developer'); |
67 | $this->assertSame(200, $client->getResponse()->getStatusCode()); | 67 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
68 | $this->assertSame(count($nbClients), $crawler->filter('ul[class=collapsible] li')->count()); | 68 | $this->assertSame(\count($nbClients), $crawler->filter('ul[class=collapsible] li')->count()); |
69 | } | 69 | } |
70 | 70 | ||
71 | public function testDeveloperHowto() | 71 | public function testDeveloperHowto() |
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 9722986e..58b617f3 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -28,7 +28,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
28 | 28 | ||
29 | $this->assertSame($entry->getTitle(), $content['title']); | 29 | $this->assertSame($entry->getTitle(), $content['title']); |
30 | $this->assertSame($entry->getUrl(), $content['url']); | 30 | $this->assertSame($entry->getUrl(), $content['url']); |
31 | $this->assertCount(count($entry->getTags()), $content['tags']); | 31 | $this->assertCount(\count($entry->getTags()), $content['tags']); |
32 | $this->assertSame($entry->getUserName(), $content['user_name']); | 32 | $this->assertSame($entry->getUserName(), $content['user_name']); |
33 | $this->assertSame($entry->getUserEmail(), $content['user_email']); | 33 | $this->assertSame($entry->getUserEmail(), $content['user_email']); |
34 | $this->assertSame($entry->getUserId(), $content['user_id']); | 34 | $this->assertSame($entry->getUserId(), $content['user_id']); |
@@ -127,7 +127,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
127 | 127 | ||
128 | $content = json_decode($this->client->getResponse()->getContent(), true); | 128 | $content = json_decode($this->client->getResponse()->getContent(), true); |
129 | 129 | ||
130 | $this->assertGreaterThanOrEqual(1, count($content)); | 130 | $this->assertGreaterThanOrEqual(1, \count($content)); |
131 | $this->assertNotEmpty($content['_embedded']['items']); | 131 | $this->assertNotEmpty($content['_embedded']['items']); |
132 | $this->assertGreaterThanOrEqual(1, $content['total']); | 132 | $this->assertGreaterThanOrEqual(1, $content['total']); |
133 | $this->assertSame(1, $content['page']); | 133 | $this->assertSame(1, $content['page']); |
@@ -154,7 +154,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
154 | 154 | ||
155 | $content = json_decode($this->client->getResponse()->getContent(), true); | 155 | $content = json_decode($this->client->getResponse()->getContent(), true); |
156 | 156 | ||
157 | $this->assertGreaterThanOrEqual(1, count($content)); | 157 | $this->assertGreaterThanOrEqual(1, \count($content)); |
158 | $this->assertArrayHasKey('items', $content['_embedded']); | 158 | $this->assertArrayHasKey('items', $content['_embedded']); |
159 | $this->assertGreaterThanOrEqual(0, $content['total']); | 159 | $this->assertGreaterThanOrEqual(0, $content['total']); |
160 | $this->assertSame(1, $content['page']); | 160 | $this->assertSame(1, $content['page']); |
@@ -206,7 +206,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
206 | 206 | ||
207 | $content = json_decode($this->client->getResponse()->getContent(), true); | 207 | $content = json_decode($this->client->getResponse()->getContent(), true); |
208 | 208 | ||
209 | $this->assertGreaterThanOrEqual(1, count($content)); | 209 | $this->assertGreaterThanOrEqual(1, \count($content)); |
210 | $this->assertArrayHasKey('items', $content['_embedded']); | 210 | $this->assertArrayHasKey('items', $content['_embedded']); |
211 | $this->assertGreaterThanOrEqual(1, $content['total']); | 211 | $this->assertGreaterThanOrEqual(1, $content['total']); |
212 | $this->assertSame(1, $content['page']); | 212 | $this->assertSame(1, $content['page']); |
@@ -250,7 +250,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
250 | 250 | ||
251 | $content = json_decode($this->client->getResponse()->getContent(), true); | 251 | $content = json_decode($this->client->getResponse()->getContent(), true); |
252 | 252 | ||
253 | $this->assertGreaterThanOrEqual(1, count($content)); | 253 | $this->assertGreaterThanOrEqual(1, \count($content)); |
254 | $this->assertNotEmpty($content['_embedded']['items']); | 254 | $this->assertNotEmpty($content['_embedded']['items']); |
255 | $this->assertGreaterThanOrEqual(1, $content['total']); | 255 | $this->assertGreaterThanOrEqual(1, $content['total']); |
256 | $this->assertSame(1, $content['page']); | 256 | $this->assertSame(1, $content['page']); |
@@ -278,7 +278,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
278 | 278 | ||
279 | $content = json_decode($this->client->getResponse()->getContent(), true); | 279 | $content = json_decode($this->client->getResponse()->getContent(), true); |
280 | 280 | ||
281 | $this->assertGreaterThanOrEqual(1, count($content)); | 281 | $this->assertGreaterThanOrEqual(1, \count($content)); |
282 | $this->assertNotEmpty($content['_embedded']['items']); | 282 | $this->assertNotEmpty($content['_embedded']['items']); |
283 | $this->assertGreaterThanOrEqual(1, $content['total']); | 283 | $this->assertGreaterThanOrEqual(1, $content['total']); |
284 | $this->assertSame(1, $content['page']); | 284 | $this->assertSame(1, $content['page']); |
@@ -305,7 +305,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
305 | 305 | ||
306 | $content = json_decode($this->client->getResponse()->getContent(), true); | 306 | $content = json_decode($this->client->getResponse()->getContent(), true); |
307 | 307 | ||
308 | $this->assertGreaterThanOrEqual(1, count($content)); | 308 | $this->assertGreaterThanOrEqual(1, \count($content)); |
309 | $this->assertNotEmpty($content['_embedded']['items']); | 309 | $this->assertNotEmpty($content['_embedded']['items']); |
310 | $this->assertGreaterThanOrEqual(1, $content['total']); | 310 | $this->assertGreaterThanOrEqual(1, $content['total']); |
311 | $this->assertSame(1, $content['page']); | 311 | $this->assertSame(1, $content['page']); |
@@ -342,7 +342,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
342 | 342 | ||
343 | $content = json_decode($this->client->getResponse()->getContent(), true); | 343 | $content = json_decode($this->client->getResponse()->getContent(), true); |
344 | 344 | ||
345 | $this->assertGreaterThanOrEqual(1, count($content)); | 345 | $this->assertGreaterThanOrEqual(1, \count($content)); |
346 | $this->assertNotEmpty($content['_embedded']['items']); | 346 | $this->assertNotEmpty($content['_embedded']['items']); |
347 | $this->assertGreaterThanOrEqual(1, $content['total']); | 347 | $this->assertGreaterThanOrEqual(1, $content['total']); |
348 | $this->assertSame(1, $content['page']); | 348 | $this->assertSame(1, $content['page']); |
@@ -370,7 +370,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
370 | 370 | ||
371 | $content = json_decode($this->client->getResponse()->getContent(), true); | 371 | $content = json_decode($this->client->getResponse()->getContent(), true); |
372 | 372 | ||
373 | $this->assertGreaterThanOrEqual(1, count($content)); | 373 | $this->assertGreaterThanOrEqual(1, \count($content)); |
374 | $this->assertEmpty($content['_embedded']['items']); | 374 | $this->assertEmpty($content['_embedded']['items']); |
375 | $this->assertSame(0, $content['total']); | 375 | $this->assertSame(0, $content['total']); |
376 | $this->assertSame(1, $content['page']); | 376 | $this->assertSame(1, $content['page']); |
@@ -608,7 +608,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
608 | $this->assertSame($entry->getId(), $content['id']); | 608 | $this->assertSame($entry->getId(), $content['id']); |
609 | $this->assertSame($entry->getUrl(), $content['url']); | 609 | $this->assertSame($entry->getUrl(), $content['url']); |
610 | $this->assertSame('New awesome title', $content['title']); | 610 | $this->assertSame('New awesome title', $content['title']); |
611 | $this->assertGreaterThanOrEqual(1, count($content['tags']), 'We force only one tag'); | 611 | $this->assertGreaterThanOrEqual(1, \count($content['tags']), 'We force only one tag'); |
612 | $this->assertSame(1, $content['user_id']); | 612 | $this->assertSame(1, $content['user_id']); |
613 | $this->assertSame('de_AT', $content['language']); | 613 | $this->assertSame('de_AT', $content['language']); |
614 | $this->assertSame('http://preview.io/picture.jpg', $content['preview_picture']); | 614 | $this->assertSame('http://preview.io/picture.jpg', $content['preview_picture']); |
@@ -647,7 +647,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
647 | 647 | ||
648 | $this->assertSame($entry->getId(), $content['id']); | 648 | $this->assertSame($entry->getId(), $content['id']); |
649 | $this->assertSame($entry->getUrl(), $content['url']); | 649 | $this->assertSame($entry->getUrl(), $content['url']); |
650 | $this->assertGreaterThanOrEqual(1, count($content['tags']), 'We force only one tag'); | 650 | $this->assertGreaterThanOrEqual(1, \count($content['tags']), 'We force only one tag'); |
651 | $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string'); | 651 | $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string'); |
652 | $this->assertSame($previousContent, $content['content'], 'Ensure content has not moved'); | 652 | $this->assertSame($previousContent, $content['content'], 'Ensure content has not moved'); |
653 | $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved'); | 653 | $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved'); |
@@ -772,7 +772,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
772 | $this->markTestSkipped('No content found in db.'); | 772 | $this->markTestSkipped('No content found in db.'); |
773 | } | 773 | } |
774 | 774 | ||
775 | $nbTags = count($entry->getTags()); | 775 | $nbTags = \count($entry->getTags()); |
776 | 776 | ||
777 | $newTags = 'tag1,tag2,tag3'; | 777 | $newTags = 'tag1,tag2,tag3'; |
778 | 778 | ||
@@ -783,7 +783,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
783 | $content = json_decode($this->client->getResponse()->getContent(), true); | 783 | $content = json_decode($this->client->getResponse()->getContent(), true); |
784 | 784 | ||
785 | $this->assertArrayHasKey('tags', $content); | 785 | $this->assertArrayHasKey('tags', $content); |
786 | $this->assertSame($nbTags + 3, count($content['tags'])); | 786 | $this->assertSame($nbTags + 3, \count($content['tags'])); |
787 | 787 | ||
788 | $entryDB = $this->client->getContainer() | 788 | $entryDB = $this->client->getContainer() |
789 | ->get('doctrine.orm.entity_manager') | 789 | ->get('doctrine.orm.entity_manager') |
@@ -813,7 +813,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
813 | } | 813 | } |
814 | 814 | ||
815 | // hydrate the tags relations | 815 | // hydrate the tags relations |
816 | $nbTags = count($entry->getTags()); | 816 | $nbTags = \count($entry->getTags()); |
817 | $tag = $entry->getTags()[0]; | 817 | $tag = $entry->getTags()[0]; |
818 | 818 | ||
819 | $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '/tags/' . $tag->getId() . '.json'); | 819 | $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '/tags/' . $tag->getId() . '.json'); |
@@ -823,7 +823,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
823 | $content = json_decode($this->client->getResponse()->getContent(), true); | 823 | $content = json_decode($this->client->getResponse()->getContent(), true); |
824 | 824 | ||
825 | $this->assertArrayHasKey('tags', $content); | 825 | $this->assertArrayHasKey('tags', $content); |
826 | $this->assertSame($nbTags - 1, count($content['tags'])); | 826 | $this->assertSame($nbTags - 1, \count($content['tags'])); |
827 | } | 827 | } |
828 | 828 | ||
829 | public function testSaveIsArchivedAfterPost() | 829 | public function testSaveIsArchivedAfterPost() |
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index a436be79..bf0068b4 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -174,7 +174,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
174 | 174 | ||
175 | public function testPostWithMultipleAuthors() | 175 | public function testPostWithMultipleAuthors() |
176 | { | 176 | { |
177 | $url = 'http://www.liberation.fr/planete/2017/04/05/donald-trump-et-xi-jinping-tentative-de-flirt-en-floride_1560768'; | 177 | $url = 'https://www.liberation.fr/planete/2017/04/05/donald-trump-et-xi-jinping-tentative-de-flirt-en-floride_1560768'; |
178 | $this->logInAs('admin'); | 178 | $this->logInAs('admin'); |
179 | $client = $this->getClient(); | 179 | $client = $this->getClient(); |
180 | 180 | ||
@@ -197,6 +197,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
197 | ->getRepository('WallabagCoreBundle:Entry') | 197 | ->getRepository('WallabagCoreBundle:Entry') |
198 | ->findByUrlAndUserId($url, $this->getLoggedInUserId()); | 198 | ->findByUrlAndUserId($url, $this->getLoggedInUserId()); |
199 | 199 | ||
200 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); | ||
200 | $authors = $content->getPublishedBy(); | 201 | $authors = $content->getPublishedBy(); |
201 | $this->assertSame('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s')); | 202 | $this->assertSame('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s')); |
202 | $this->assertSame('fr', $content->getLanguage()); | 203 | $this->assertSame('fr', $content->getLanguage()); |
@@ -524,7 +525,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
524 | 525 | ||
525 | $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); | 526 | $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); |
526 | $this->assertContains('My updated title hehe :)', $title[0]); | 527 | $this->assertContains('My updated title hehe :)', $title[0]); |
527 | $this->assertSame(1, count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']))); | 528 | $this->assertSame(1, \count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']))); |
528 | $this->assertNotContains('example.io', trim($stats[0])); | 529 | $this->assertNotContains('example.io', trim($stats[0])); |
529 | } | 530 | } |
530 | 531 | ||
@@ -1325,16 +1326,12 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1325 | 'http://www.hao123.com/shequ?__noscript__-=1', | 1326 | 'http://www.hao123.com/shequ?__noscript__-=1', |
1326 | 'zh_CN', | 1327 | 'zh_CN', |
1327 | ], | 1328 | ], |
1328 | 'de_AT' => [ | 1329 | 'ru' => [ |
1329 | 'https://buy.garmin.com/de-AT/AT/catalog/product/compareResult.ep?compareProduct=112885&compareProduct=36728', | 1330 | 'https://www.kp.ru/daily/26879.7/3921982/', |
1330 | 'de_AT', | 1331 | 'ru', |
1331 | ], | ||
1332 | 'ru_RU' => [ | ||
1333 | 'http://netler.ru/ikt/windows-error-reporting.htm', | ||
1334 | 'ru_RU', | ||
1335 | ], | 1332 | ], |
1336 | 'pt_BR' => [ | 1333 | 'pt_BR' => [ |
1337 | 'http://precodoscombustiveis.com.br/postos/cidade/4121/pr/maringa', | 1334 | 'https://politica.estadao.com.br/noticias/eleicoes,campanha-catatonica,70002491983', |
1338 | 'pt_BR', | 1335 | 'pt_BR', |
1339 | ], | 1336 | ], |
1340 | 'fucked_list_of_languages' => [ | 1337 | 'fucked_list_of_languages' => [ |
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php index ab7f23cc..6f3308e5 100644 --- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | |||
@@ -180,7 +180,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
180 | 180 | ||
181 | $this->assertGreaterThan(1, $csv); | 181 | $this->assertGreaterThan(1, $csv); |
182 | // +1 for title line | 182 | // +1 for title line |
183 | $this->assertSame(count($contentInDB) + 1, count($csv)); | 183 | $this->assertSame(\count($contentInDB) + 1, \count($csv)); |
184 | $this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); | 184 | $this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); |
185 | $this->assertContains($contentInDB[0]['title'], $csv[1]); | 185 | $this->assertContains($contentInDB[0]['title'], $csv[1]); |
186 | $this->assertContains($contentInDB[0]['url'], $csv[1]); | 186 | $this->assertContains($contentInDB[0]['url'], $csv[1]); |
@@ -272,7 +272,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
272 | 272 | ||
273 | $content = new \SimpleXMLElement($client->getResponse()->getContent()); | 273 | $content = new \SimpleXMLElement($client->getResponse()->getContent()); |
274 | $this->assertGreaterThan(0, $content->count()); | 274 | $this->assertGreaterThan(0, $content->count()); |
275 | $this->assertSame(count($contentInDB), $content->count()); | 275 | $this->assertSame(\count($contentInDB), $content->count()); |
276 | $this->assertNotEmpty('id', (string) $content->entry[0]->id); | 276 | $this->assertNotEmpty('id', (string) $content->entry[0]->id); |
277 | $this->assertNotEmpty('title', (string) $content->entry[0]->title); | 277 | $this->assertNotEmpty('title', (string) $content->entry[0]->title); |
278 | $this->assertNotEmpty('url', (string) $content->entry[0]->url); | 278 | $this->assertNotEmpty('url', (string) $content->entry[0]->url); |
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php index 5a973a7e..768f4c07 100644 --- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php | |||
@@ -98,7 +98,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
98 | $tags[$key] = $tag->getLabel(); | 98 | $tags[$key] = $tag->getLabel(); |
99 | } | 99 | } |
100 | 100 | ||
101 | $this->assertGreaterThanOrEqual(2, count($tags)); | 101 | $this->assertGreaterThanOrEqual(2, \count($tags)); |
102 | $this->assertNotFalse(array_search('foo2', $tags, true), 'Tag foo2 is assigned to the entry'); | 102 | $this->assertNotFalse(array_search('foo2', $tags, true), 'Tag foo2 is assigned to the entry'); |
103 | $this->assertNotFalse(array_search('bar2', $tags, true), 'Tag bar2 is assigned to the entry'); | 103 | $this->assertNotFalse(array_search('bar2', $tags, true), 'Tag bar2 is assigned to the entry'); |
104 | } | 104 | } |
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php index 51df8de1..3dd9273c 100644 --- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | |||
@@ -531,6 +531,377 @@ class ContentProxyTest extends TestCase | |||
531 | $this->assertSame('1.1.1.1', $entry->getDomainName()); | 531 | $this->assertSame('1.1.1.1', $entry->getDomainName()); |
532 | } | 532 | } |
533 | 533 | ||
534 | public function testWebsiteWithValidUTF8Title_doNothing() | ||
535 | { | ||
536 | // You can use https://www.online-toolz.com/tools/text-hex-convertor.php to convert UTF-8 text <=> hex | ||
537 | // See http://graphemica.com for more info about the characters | ||
538 | // '😻ℤz' (U+1F63B or F09F98BB; U+2124 or E284A4; U+007A or 7A) in hexadecimal and UTF-8 | ||
539 | $actualTitle = $this->hexToStr('F09F98BB' . 'E284A4' . '7A'); | ||
540 | |||
541 | $tagger = $this->getTaggerMock(); | ||
542 | $tagger->expects($this->once()) | ||
543 | ->method('tag'); | ||
544 | |||
545 | $graby = $this->getMockBuilder('Graby\Graby') | ||
546 | ->setMethods(['fetchContent']) | ||
547 | ->disableOriginalConstructor() | ||
548 | ->getMock(); | ||
549 | |||
550 | $graby->expects($this->any()) | ||
551 | ->method('fetchContent') | ||
552 | ->willReturn([ | ||
553 | 'html' => false, | ||
554 | 'title' => $actualTitle, | ||
555 | 'url' => '', | ||
556 | 'content_type' => 'text/html', | ||
557 | 'language' => '', | ||
558 | ]); | ||
559 | |||
560 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); | ||
561 | $entry = new Entry(new User()); | ||
562 | $proxy->updateEntry($entry, 'http://0.0.0.0'); | ||
563 | |||
564 | // '😻ℤz' (U+1F63B or F09F98BB; U+2124 or E284A4; U+007A or 7A) in hexadecimal and UTF-8 | ||
565 | $expectedTitle = 'F09F98BB' . 'E284A4' . '7A'; | ||
566 | $this->assertSame($expectedTitle, $this->strToHex($entry->getTitle())); | ||
567 | } | ||
568 | |||
569 | public function testWebsiteWithInvalidUTF8Title_removeInvalidCharacter() | ||
570 | { | ||
571 | // See http://graphemica.com for more info about the characters | ||
572 | // 'a€b' (61;80;62) in hexadecimal and WINDOWS-1252 - but 80 is a invalid UTF-8 character. | ||
573 | // The correct UTF-8 € character (U+20AC) is E282AC | ||
574 | $actualTitle = $this->hexToStr('61' . '80' . '62'); | ||
575 | |||
576 | $tagger = $this->getTaggerMock(); | ||
577 | $tagger->expects($this->once()) | ||
578 | ->method('tag'); | ||
579 | |||
580 | $graby = $this->getMockBuilder('Graby\Graby') | ||
581 | ->setMethods(['fetchContent']) | ||
582 | ->disableOriginalConstructor() | ||
583 | ->getMock(); | ||
584 | |||
585 | $graby->expects($this->any()) | ||
586 | ->method('fetchContent') | ||
587 | ->willReturn([ | ||
588 | 'html' => false, | ||
589 | 'title' => $actualTitle, | ||
590 | 'url' => '', | ||
591 | 'content_type' => 'text/html', | ||
592 | 'language' => '', | ||
593 | ]); | ||
594 | |||
595 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); | ||
596 | $entry = new Entry(new User()); | ||
597 | $proxy->updateEntry($entry, 'http://0.0.0.0'); | ||
598 | |||
599 | // 'ab' (61;62) because all invalid UTF-8 character (like 80) are removed | ||
600 | $expectedTitle = '61' . '62'; | ||
601 | $this->assertSame($expectedTitle, $this->strToHex($entry->getTitle())); | ||
602 | } | ||
603 | |||
604 | public function testPdfWithUTF16BETitle_convertToUTF8() | ||
605 | { | ||
606 | // See http://graphemica.com for more info about the characters | ||
607 | // '😻' (U+1F63B;D83DDE3B) in hexadecimal and as UTF16BE | ||
608 | $actualTitle = $this->hexToStr('D83DDE3B'); | ||
609 | |||
610 | $tagger = $this->getTaggerMock(); | ||
611 | $tagger->expects($this->once()) | ||
612 | ->method('tag'); | ||
613 | |||
614 | $graby = $this->getMockBuilder('Graby\Graby') | ||
615 | ->setMethods(['fetchContent']) | ||
616 | ->disableOriginalConstructor() | ||
617 | ->getMock(); | ||
618 | |||
619 | $graby->expects($this->any()) | ||
620 | ->method('fetchContent') | ||
621 | ->willReturn([ | ||
622 | 'html' => false, | ||
623 | 'title' => $actualTitle, | ||
624 | 'url' => '', | ||
625 | 'content_type' => 'application/pdf', | ||
626 | 'language' => '', | ||
627 | ]); | ||
628 | |||
629 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); | ||
630 | $entry = new Entry(new User()); | ||
631 | $proxy->updateEntry($entry, 'http://0.0.0.0'); | ||
632 | |||
633 | // '😻' (U+1F63B or F09F98BB) in hexadecimal and UTF-8 | ||
634 | $expectedTitle = 'F09F98BB'; | ||
635 | $this->assertSame($expectedTitle, $this->strToHex($entry->getTitle())); | ||
636 | } | ||
637 | |||
638 | public function testPdfWithUTF8Title_doNothing() | ||
639 | { | ||
640 | // See http://graphemica.com for more info about the characters | ||
641 | // '😻' (U+1F63B;D83DDE3B) in hexadecimal and as UTF8 | ||
642 | $actualTitle = $this->hexToStr('F09F98BB'); | ||
643 | |||
644 | $tagger = $this->getTaggerMock(); | ||
645 | $tagger->expects($this->once()) | ||
646 | ->method('tag'); | ||
647 | |||
648 | $graby = $this->getMockBuilder('Graby\Graby') | ||
649 | ->setMethods(['fetchContent']) | ||
650 | ->disableOriginalConstructor() | ||
651 | ->getMock(); | ||
652 | |||
653 | $graby->expects($this->any()) | ||
654 | ->method('fetchContent') | ||
655 | ->willReturn([ | ||
656 | 'html' => false, | ||
657 | 'title' => $actualTitle, | ||
658 | 'url' => '', | ||
659 | 'content_type' => 'application/pdf', | ||
660 | 'language' => '', | ||
661 | ]); | ||
662 | |||
663 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); | ||
664 | $entry = new Entry(new User()); | ||
665 | $proxy->updateEntry($entry, 'http://0.0.0.0'); | ||
666 | |||
667 | // '😻' (U+1F63B or F09F98BB) in hexadecimal and UTF-8 | ||
668 | $expectedTitle = 'F09F98BB'; | ||
669 | $this->assertSame($expectedTitle, $this->strToHex($entry->getTitle())); | ||
670 | } | ||
671 | |||
672 | public function testPdfWithWINDOWS1252Title_convertToUTF8() | ||
673 | { | ||
674 | // See http://graphemica.com for more info about the characters | ||
675 | // '€' (80) in hexadecimal and WINDOWS-1252 | ||
676 | $actualTitle = $this->hexToStr('80'); | ||
677 | |||
678 | $tagger = $this->getTaggerMock(); | ||
679 | $tagger->expects($this->once()) | ||
680 | ->method('tag'); | ||
681 | |||
682 | $graby = $this->getMockBuilder('Graby\Graby') | ||
683 | ->setMethods(['fetchContent']) | ||
684 | ->disableOriginalConstructor() | ||
685 | ->getMock(); | ||
686 | |||
687 | $graby->expects($this->any()) | ||
688 | ->method('fetchContent') | ||
689 | ->willReturn([ | ||
690 | 'html' => false, | ||
691 | 'title' => $actualTitle, | ||
692 | 'url' => '', | ||
693 | 'content_type' => 'application/pdf', | ||
694 | 'language' => '', | ||
695 | ]); | ||
696 | |||
697 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); | ||
698 | $entry = new Entry(new User()); | ||
699 | $proxy->updateEntry($entry, 'http://0.0.0.0'); | ||
700 | |||
701 | // '€' (U+20AC or E282AC) in hexadecimal and UTF-8 | ||
702 | $expectedTitle = 'E282AC'; | ||
703 | $this->assertSame($expectedTitle, $this->strToHex($entry->getTitle())); | ||
704 | } | ||
705 | |||
706 | public function testPdfWithInvalidCharacterInTitle_removeInvalidCharacter() | ||
707 | { | ||
708 | // See http://graphemica.com for more info about the characters | ||
709 | // '😻ℤ�z' (U+1F63B or F09F98BB; U+2124 or E284A4; invalid character 81; U+007A or 7A) in hexadecimal and UTF-8 | ||
710 | // 0x81 is not a valid character for UTF16, UTF8 and WINDOWS-1252 | ||
711 | $actualTitle = $this->hexToStr('F09F98BB' . 'E284A4' . '81' . '7A'); | ||
712 | |||
713 | $tagger = $this->getTaggerMock(); | ||
714 | $tagger->expects($this->once()) | ||
715 | ->method('tag'); | ||
716 | |||
717 | $graby = $this->getMockBuilder('Graby\Graby') | ||
718 | ->setMethods(['fetchContent']) | ||
719 | ->disableOriginalConstructor() | ||
720 | ->getMock(); | ||
721 | |||
722 | $graby->expects($this->any()) | ||
723 | ->method('fetchContent') | ||
724 | ->willReturn([ | ||
725 | 'html' => false, | ||
726 | 'title' => $actualTitle, | ||
727 | 'url' => '', | ||
728 | 'content_type' => 'application/pdf', | ||
729 | 'language' => '', | ||
730 | ]); | ||
731 | |||
732 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); | ||
733 | $entry = new Entry(new User()); | ||
734 | $proxy->updateEntry($entry, 'http://0.0.0.0'); | ||
735 | |||
736 | // '😻ℤz' (U+1F63B or F09F98BB; U+2124 or E284A4; U+007A or 7A) in hexadecimal and UTF-8 | ||
737 | // the 0x81 (represented by �) is invalid for UTF16, UTF8 and WINDOWS-1252 and is removed | ||
738 | $expectedTitle = 'F09F98BB' . 'E284A4' . '7A'; | ||
739 | $this->assertSame($expectedTitle, $this->strToHex($entry->getTitle())); | ||
740 | } | ||
741 | |||
742 | /** | ||
743 | * Data provider for testWithChangedUrl. | ||
744 | * | ||
745 | * Arrays contain the following values: | ||
746 | * $entry_url | ||
747 | * $origin_url | ||
748 | * $content_url | ||
749 | * $expected_entry_url | ||
750 | * $expected_origin_url | ||
751 | * $expected_domain | ||
752 | */ | ||
753 | public function dataForChangedUrl() | ||
754 | { | ||
755 | return [ | ||
756 | 'normal' => [ | ||
757 | 'http://0.0.0.0', | ||
758 | null, | ||
759 | 'http://1.1.1.1', | ||
760 | 'http://1.1.1.1', | ||
761 | 'http://0.0.0.0', | ||
762 | '1.1.1.1', | ||
763 | ], | ||
764 | 'origin already set' => [ | ||
765 | 'http://0.0.0.0', | ||
766 | 'http://hello', | ||
767 | 'http://1.1.1.1', | ||
768 | 'http://1.1.1.1', | ||
769 | 'http://hello', | ||
770 | '1.1.1.1', | ||
771 | ], | ||
772 | 'trailing slash' => [ | ||
773 | 'https://example.com/hello-world', | ||
774 | null, | ||
775 | 'https://example.com/hello-world/', | ||
776 | 'https://example.com/hello-world/', | ||
777 | null, | ||
778 | 'example.com', | ||
779 | ], | ||
780 | 'query string in fetched content' => [ | ||
781 | 'https://example.org/hello', | ||
782 | null, | ||
783 | 'https://example.org/hello?world=1', | ||
784 | 'https://example.org/hello?world=1', | ||
785 | 'https://example.org/hello', | ||
786 | 'example.org', | ||
787 | ], | ||
788 | 'fragment in fetched content' => [ | ||
789 | 'https://example.org/hello', | ||
790 | null, | ||
791 | 'https://example.org/hello#world', | ||
792 | 'https://example.org/hello', | ||
793 | null, | ||
794 | 'example.org', | ||
795 | ], | ||
796 | 'fragment and query string in fetched content' => [ | ||
797 | 'https://example.org/hello', | ||
798 | null, | ||
799 | 'https://example.org/hello?foo#world', | ||
800 | 'https://example.org/hello?foo#world', | ||
801 | 'https://example.org/hello', | ||
802 | 'example.org', | ||
803 | ], | ||
804 | 'different path and query string in fetch content' => [ | ||
805 | 'https://example.org/hello', | ||
806 | null, | ||
807 | 'https://example.org/world?foo', | ||
808 | 'https://example.org/world?foo', | ||
809 | 'https://example.org/hello', | ||
810 | 'example.org', | ||
811 | ], | ||
812 | 'feedproxy ignore list test' => [ | ||
813 | 'http://feedproxy.google.com/~r/Wallabag/~3/helloworld', | ||
814 | null, | ||
815 | 'https://example.org/hello-wallabag', | ||
816 | 'https://example.org/hello-wallabag', | ||
817 | null, | ||
818 | 'example.org', | ||
819 | ], | ||
820 | 'feedproxy ignore list test with origin url already set' => [ | ||
821 | 'http://feedproxy.google.com/~r/Wallabag/~3/helloworld', | ||
822 | 'https://example.org/this-is-source', | ||
823 | 'https://example.org/hello-wallabag', | ||
824 | 'https://example.org/hello-wallabag', | ||
825 | 'https://example.org/this-is-source', | ||
826 | 'example.org', | ||
827 | ], | ||
828 | 'lemonde ignore pattern test' => [ | ||
829 | 'http://www.lemonde.fr/tiny/url', | ||
830 | null, | ||
831 | 'http://example.com/hello-world', | ||
832 | 'http://example.com/hello-world', | ||
833 | null, | ||
834 | 'example.com', | ||
835 | ], | ||
836 | ]; | ||
837 | } | ||
838 | |||
839 | /** | ||
840 | * @dataProvider dataForChangedUrl | ||
841 | */ | ||
842 | public function testWithChangedUrl($entry_url, $origin_url, $content_url, $expected_entry_url, $expected_origin_url, $expected_domain) | ||
843 | { | ||
844 | $tagger = $this->getTaggerMock(); | ||
845 | $tagger->expects($this->once()) | ||
846 | ->method('tag'); | ||
847 | |||
848 | $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage, true); | ||
849 | $entry = new Entry(new User()); | ||
850 | $entry->setOriginUrl($origin_url); | ||
851 | $proxy->updateEntry( | ||
852 | $entry, | ||
853 | $entry_url, | ||
854 | [ | ||
855 | 'html' => false, | ||
856 | 'title' => '', | ||
857 | 'url' => $content_url, | ||
858 | 'content_type' => '', | ||
859 | 'language' => '', | ||
860 | ], | ||
861 | true | ||
862 | ); | ||
863 | |||
864 | $this->assertSame($expected_entry_url, $entry->getUrl()); | ||
865 | $this->assertSame($expected_domain, $entry->getDomainName()); | ||
866 | $this->assertSame($expected_origin_url, $entry->getOriginUrl()); | ||
867 | } | ||
868 | |||
869 | /** | ||
870 | * https://stackoverflow.com/a/18506801. | ||
871 | * | ||
872 | * @param $string | ||
873 | * | ||
874 | * @return string | ||
875 | */ | ||
876 | private function strToHex($string) | ||
877 | { | ||
878 | $hex = ''; | ||
879 | for ($i = 0; $i < \strlen($string); ++$i) { | ||
880 | $ord = \ord($string[$i]); | ||
881 | $hexCode = dechex($ord); | ||
882 | $hex .= substr('0' . $hexCode, -2); | ||
883 | } | ||
884 | |||
885 | return strtoupper($hex); | ||
886 | } | ||
887 | |||
888 | /** | ||
889 | * https://stackoverflow.com/a/18506801. | ||
890 | * | ||
891 | * @param $hex | ||
892 | * | ||
893 | * @return string | ||
894 | */ | ||
895 | private function hexToStr($hex) | ||
896 | { | ||
897 | $string = ''; | ||
898 | for ($i = 0; $i < \strlen($hex) - 1; $i += 2) { | ||
899 | $string .= \chr(hexdec($hex[$i] . $hex[$i + 1])); | ||
900 | } | ||
901 | |||
902 | return $string; | ||
903 | } | ||
904 | |||
534 | private function getTaggerMock() | 905 | private function getTaggerMock() |
535 | { | 906 | { |
536 | return $this->getMockBuilder(RuleBasedTagger::class) | 907 | return $this->getMockBuilder(RuleBasedTagger::class) |
diff --git a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php index ddb7a65a..cd3e41e9 100644 --- a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php | |||
@@ -121,7 +121,7 @@ class ChromeControllerTest extends WallabagCoreTestCase | |||
121 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); | 121 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); |
122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.usinenouvelle.com is ok'); | 122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.usinenouvelle.com is ok'); |
123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.usinenouvelle.com is ok'); | 123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.usinenouvelle.com is ok'); |
124 | $this->assertSame(1, count($content->getTags())); | 124 | $this->assertSame(1, \count($content->getTags())); |
125 | 125 | ||
126 | $createdAt = $content->getCreatedAt(); | 126 | $createdAt = $content->getCreatedAt(); |
127 | $this->assertSame('2011', $createdAt->format('Y')); | 127 | $this->assertSame('2011', $createdAt->format('Y')); |
diff --git a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php index fc02c813..dc5ed6d0 100644 --- a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php | |||
@@ -122,7 +122,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
122 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok'); | 122 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok'); |
123 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok'); | 123 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok'); |
124 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok'); | 124 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok'); |
125 | $this->assertSame(3, count($content->getTags())); | 125 | $this->assertSame(3, \count($content->getTags())); |
126 | 126 | ||
127 | $content = $client->getContainer() | 127 | $content = $client->getContainer() |
128 | ->get('doctrine.orm.entity_manager') | 128 | ->get('doctrine.orm.entity_manager') |
diff --git a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php index dacdf488..7390fa88 100644 --- a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php | |||
@@ -114,15 +114,17 @@ class InstapaperControllerTest extends WallabagCoreTestCase | |||
114 | ->get('doctrine.orm.entity_manager') | 114 | ->get('doctrine.orm.entity_manager') |
115 | ->getRepository('WallabagCoreBundle:Entry') | 115 | ->getRepository('WallabagCoreBundle:Entry') |
116 | ->findByUrlAndUserId( | 116 | ->findByUrlAndUserId( |
117 | 'http://www.liberation.fr/societe/2012/12/06/baumettes-un-tour-en-cellule_865551', | 117 | 'https://www.liberation.fr/societe/2012/12/06/baumettes-un-tour-en-cellule_865551', |
118 | $this->getLoggedInUserId() | 118 | $this->getLoggedInUserId() |
119 | ); | 119 | ); |
120 | 120 | ||
121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok'); | 121 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); |
122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok'); | 122 | |
123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok'); | 123 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.liberation.fr is ok'); |
124 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.liberation.fr is ok'); | ||
125 | $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.liberation.fr is ok'); | ||
124 | $this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag'); | 126 | $this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag'); |
125 | $this->assertSame(1, count($content->getTags())); | 127 | $this->assertSame(1, \count($content->getTags())); |
126 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 128 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
127 | 129 | ||
128 | $content = $client->getContainer() | 130 | $content = $client->getContainer() |
@@ -136,7 +138,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase | |||
136 | $this->assertContains('foot', $content->getTags()); | 138 | $this->assertContains('foot', $content->getTags()); |
137 | $this->assertContains('test_tag', $content->getTags()); | 139 | $this->assertContains('test_tag', $content->getTags()); |
138 | 140 | ||
139 | $this->assertSame(2, count($content->getTags())); | 141 | $this->assertSame(2, \count($content->getTags())); |
140 | } | 142 | } |
141 | 143 | ||
142 | public function testImportInstapaperWithFileAndMarkAllAsRead() | 144 | public function testImportInstapaperWithFileAndMarkAllAsRead() |
diff --git a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php index 1135f32e..80819f45 100644 --- a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php | |||
@@ -127,7 +127,7 @@ class PinboardControllerTest extends WallabagCoreTestCase | |||
127 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); | 127 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); |
128 | $this->assertContains('varnish', $tags, 'It includes the "varnish" tag'); | 128 | $this->assertContains('varnish', $tags, 'It includes the "varnish" tag'); |
129 | $this->assertContains('php', $tags, 'It includes the "php" tag'); | 129 | $this->assertContains('php', $tags, 'It includes the "php" tag'); |
130 | $this->assertSame(3, count($tags)); | 130 | $this->assertSame(3, \count($tags)); |
131 | 131 | ||
132 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 132 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
133 | $this->assertSame('2016-10-26', $content->getCreatedAt()->format('Y-m-d')); | 133 | $this->assertSame('2016-10-26', $content->getCreatedAt()->format('Y-m-d')); |
diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php index 78816ad8..5619659a 100644 --- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php | |||
@@ -125,7 +125,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
125 | 125 | ||
126 | $tags = $content->getTags(); | 126 | $tags = $content->getTags(); |
127 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); | 127 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); |
128 | $this->assertSame(1, count($tags)); | 128 | $this->assertSame(1, \count($tags)); |
129 | 129 | ||
130 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 130 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
131 | $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); | 131 | $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); |
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php index e0e309b0..c67941a7 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php | |||
@@ -127,7 +127,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
127 | $tags = $content->getTags(); | 127 | $tags = $content->getTags(); |
128 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); | 128 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); |
129 | $this->assertContains('framabag', $tags, 'It includes the "framabag" tag'); | 129 | $this->assertContains('framabag', $tags, 'It includes the "framabag" tag'); |
130 | $this->assertSame(2, count($tags)); | 130 | $this->assertSame(2, \count($tags)); |
131 | 131 | ||
132 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 132 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
133 | } | 133 | } |
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php index e52b9c85..822656ba 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php | |||
@@ -115,20 +115,20 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase | |||
115 | ->get('doctrine.orm.entity_manager') | 115 | ->get('doctrine.orm.entity_manager') |
116 | ->getRepository('WallabagCoreBundle:Entry') | 116 | ->getRepository('WallabagCoreBundle:Entry') |
117 | ->findByUrlAndUserId( | 117 | ->findByUrlAndUserId( |
118 | 'http://www.liberation.fr/planete/2015/10/26/refugies-l-ue-va-creer-100-000-places-d-accueil-dans-les-balkans_1408867', | 118 | 'https://www.liberation.fr/planete/2015/10/26/refugies-l-ue-va-creer-100-000-places-d-accueil-dans-les-balkans_1408867', |
119 | $this->getLoggedInUserId() | 119 | $this->getLoggedInUserId() |
120 | ); | 120 | ); |
121 | 121 | ||
122 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); | 122 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); |
123 | 123 | ||
124 | // empty because it wasn't re-imported | 124 | // empty because it wasn't re-imported |
125 | $this->assertEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is empty'); | 125 | $this->assertEmpty($content->getMimetype(), 'Mimetype for https://www.liberation.fr is empty'); |
126 | $this->assertEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is empty'); | 126 | $this->assertEmpty($content->getPreviewPicture(), 'Preview picture for https://www.liberation.fr is empty'); |
127 | $this->assertEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is empty'); | 127 | $this->assertEmpty($content->getLanguage(), 'Language for https://www.liberation.fr is empty'); |
128 | 128 | ||
129 | $tags = $content->getTags(); | 129 | $tags = $content->getTags(); |
130 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); | 130 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); |
131 | $this->assertSame(1, count($tags)); | 131 | $this->assertSame(1, \count($tags)); |
132 | 132 | ||
133 | $content = $client->getContainer() | 133 | $content = $client->getContainer() |
134 | ->get('doctrine.orm.entity_manager') | 134 | ->get('doctrine.orm.entity_manager') |
@@ -147,7 +147,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase | |||
147 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); | 147 | $this->assertContains('foot', $tags, 'It includes the "foot" tag'); |
148 | $this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag'); | 148 | $this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag'); |
149 | $this->assertContains('blog', $tags, 'It includes the "blog" tag'); | 149 | $this->assertContains('blog', $tags, 'It includes the "blog" tag'); |
150 | $this->assertSame(3, count($tags)); | 150 | $this->assertSame(3, \count($tags)); |
151 | 151 | ||
152 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 152 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
153 | $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); | 153 | $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); |
diff --git a/tests/Wallabag/ImportBundle/fixtures/instapaper-export.csv b/tests/Wallabag/ImportBundle/fixtures/instapaper-export.csv index 7b692d00..5380bf2c 100644 --- a/tests/Wallabag/ImportBundle/fixtures/instapaper-export.csv +++ b/tests/Wallabag/ImportBundle/fixtures/instapaper-export.csv | |||
@@ -1,5 +1,5 @@ | |||
1 | URL,Title,Selection,Folder | 1 | URL,Title,Selection,Folder |
2 | http://www.liberation.fr/societe/2012/12/06/baumettes-un-tour-en-cellule_865551,Baumettes : un tour en cellule,,Unread | 2 | https://www.liberation.fr/societe/2012/12/06/baumettes-un-tour-en-cellule_865551,Baumettes : un tour en cellule,,Unread |
3 | https://redditblog.com/2016/09/20/amp-and-reactredux/,AMP and React+Redux: Why Not?,,Archive | 3 | https://redditblog.com/2016/09/20/amp-and-reactredux/,AMP and React+Redux: Why Not?,,Archive |
4 | https://medium.com/@the_minh/why-foursquare-swarm-is-still-my-favourite-social-network-e38228493e6c,Why Foursquare / Swarm is still my favourite social network,,Starred | 4 | https://medium.com/@the_minh/why-foursquare-swarm-is-still-my-favourite-social-network-e38228493e6c,Why Foursquare / Swarm is still my favourite social network,,Starred |
5 | https://www.20minutes.fr/high-tech/2077615-20170531-quoi-exactement-tweet-covfefe-donald-trump-persiste-signe,"Dis donc Donald Trump, c'est quoi exactement «covfefe»?",,test_tag | 5 | https://www.20minutes.fr/high-tech/2077615-20170531-quoi-exactement-tweet-covfefe-donald-trump-persiste-signe,"Dis donc Donald Trump, c'est quoi exactement «covfefe»?",,test_tag |
diff --git a/tests/Wallabag/ImportBundle/fixtures/wallabag-v2.json b/tests/Wallabag/ImportBundle/fixtures/wallabag-v2.json index 63c44cf9..a2142f90 100644 --- a/tests/Wallabag/ImportBundle/fixtures/wallabag-v2.json +++ b/tests/Wallabag/ImportBundle/fixtures/wallabag-v2.json | |||
@@ -21,7 +21,7 @@ | |||
21 | { | 21 | { |
22 | "id": 22, | 22 | "id": 22, |
23 | "title": "Réfugiés: l'UE va créer 100 000 places d'accueil dans les Balkans", | 23 | "title": "Réfugiés: l'UE va créer 100 000 places d'accueil dans les Balkans", |
24 | "url": "http://www.liberation.fr/planete/2015/10/26/refugies-l-ue-va-creer-100-000-places-d-accueil-dans-les-balkans_1408867", | 24 | "url": "https://www.liberation.fr/planete/2015/10/26/refugies-l-ue-va-creer-100-000-places-d-accueil-dans-les-balkans_1408867", |
25 | "is_archived": false, | 25 | "is_archived": false, |
26 | "created_at": "2016-09-08T11:55:58+0200", | 26 | "created_at": "2016-09-08T11:55:58+0200", |
27 | "updated_at": "2016-09-08T11:57:16+0200", | 27 | "updated_at": "2016-09-08T11:57:16+0200", |
diff --git a/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php b/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php index f39fa60e..aa176068 100644 --- a/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php +++ b/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php | |||
@@ -13,7 +13,7 @@ final class CountableMemorySpool extends \Swift_MemorySpool implements \Countabl | |||
13 | { | 13 | { |
14 | public function count() | 14 | public function count() |
15 | { | 15 | { |
16 | return count($this->messages); | 16 | return \count($this->messages); |
17 | } | 17 | } |
18 | 18 | ||
19 | public function getMessages() | 19 | public function getMessages() |