diff options
Diffstat (limited to 'tests')
31 files changed, 198 insertions, 52 deletions
diff --git a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php index 537283f2..2c46e0a1 100644 --- a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php +++ b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php | |||
@@ -1,6 +1,6 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace Tests\AnnotationBundle\Controller; | 3 | namespace Tests\Wallabag\AnnotationBundle\Controller; |
4 | 4 | ||
5 | use Tests\Wallabag\AnnotationBundle\WallabagAnnotationTestCase; | 5 | use Tests\Wallabag\AnnotationBundle\WallabagAnnotationTestCase; |
6 | use Wallabag\AnnotationBundle\Entity\Annotation; | 6 | use Wallabag\AnnotationBundle\Entity\Annotation; |
diff --git a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php index 090155d7..5586c70d 100644 --- a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php | |||
@@ -56,6 +56,20 @@ class DeveloperControllerTest extends WallabagCoreTestCase | |||
56 | $this->assertArrayHasKey('refresh_token', $data); | 56 | $this->assertArrayHasKey('refresh_token', $data); |
57 | } | 57 | } |
58 | 58 | ||
59 | public function testCreateTokenWithBadClientId() | ||
60 | { | ||
61 | $client = $this->getClient(); | ||
62 | $client->request('POST', '/oauth/v2/token', [ | ||
63 | 'grant_type' => 'password', | ||
64 | 'client_id' => '$WALLABAG_CLIENT_ID', | ||
65 | 'client_secret' => 'secret', | ||
66 | 'username' => 'admin', | ||
67 | 'password' => 'mypassword', | ||
68 | ]); | ||
69 | |||
70 | $this->assertSame(400, $client->getResponse()->getStatusCode()); | ||
71 | } | ||
72 | |||
59 | public function testListingClient() | 73 | public function testListingClient() |
60 | { | 74 | { |
61 | $this->logInAs('admin'); | 75 | $this->logInAs('admin'); |
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 3696f8f9..0b0c0276 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -242,6 +242,15 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
242 | $this->assertSame(2, $content['limit']); | 242 | $this->assertSame(2, $content['limit']); |
243 | } | 243 | } |
244 | 244 | ||
245 | public function testGetStarredEntriesWithBadSort() | ||
246 | { | ||
247 | $this->client->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated', 'order' => 'unknown']); | ||
248 | |||
249 | $this->assertSame(400, $this->client->getResponse()->getStatusCode()); | ||
250 | |||
251 | $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type')); | ||
252 | } | ||
253 | |||
245 | public function testGetStarredEntries() | 254 | public function testGetStarredEntries() |
246 | { | 255 | { |
247 | $this->client->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']); | 256 | $this->client->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']); |
@@ -785,7 +794,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
785 | $content = json_decode($this->client->getResponse()->getContent(), true); | 794 | $content = json_decode($this->client->getResponse()->getContent(), true); |
786 | 795 | ||
787 | $this->assertArrayHasKey('tags', $content); | 796 | $this->assertArrayHasKey('tags', $content); |
788 | $this->assertSame($nbTags + 3, \count($content['tags'])); | 797 | $this->assertCount($nbTags + 3, $content['tags']); |
789 | 798 | ||
790 | $entryDB = $this->client->getContainer() | 799 | $entryDB = $this->client->getContainer() |
791 | ->get('doctrine.orm.entity_manager') | 800 | ->get('doctrine.orm.entity_manager') |
@@ -825,7 +834,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
825 | $content = json_decode($this->client->getResponse()->getContent(), true); | 834 | $content = json_decode($this->client->getResponse()->getContent(), true); |
826 | 835 | ||
827 | $this->assertArrayHasKey('tags', $content); | 836 | $this->assertArrayHasKey('tags', $content); |
828 | $this->assertSame($nbTags - 1, \count($content['tags'])); | 837 | $this->assertCount($nbTags - 1, $content['tags']); |
829 | } | 838 | } |
830 | 839 | ||
831 | public function testSaveIsArchivedAfterPost() | 840 | public function testSaveIsArchivedAfterPost() |
diff --git a/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php index 430e548d..9daa94cd 100644 --- a/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php | |||
@@ -7,6 +7,8 @@ use Wallabag\CoreBundle\Entity\Tag; | |||
7 | 7 | ||
8 | class TagRestControllerTest extends WallabagApiTestCase | 8 | class TagRestControllerTest extends WallabagApiTestCase |
9 | { | 9 | { |
10 | private $otherUserTagLabel = 'bob'; | ||
11 | |||
10 | public function testGetUserTags() | 12 | public function testGetUserTags() |
11 | { | 13 | { |
12 | $this->client->request('GET', '/api/tags.json'); | 14 | $this->client->request('GET', '/api/tags.json'); |
@@ -19,17 +21,33 @@ class TagRestControllerTest extends WallabagApiTestCase | |||
19 | $this->assertArrayHasKey('id', $content[0]); | 21 | $this->assertArrayHasKey('id', $content[0]); |
20 | $this->assertArrayHasKey('label', $content[0]); | 22 | $this->assertArrayHasKey('label', $content[0]); |
21 | 23 | ||
24 | $tagLabels = array_map(function ($i) { | ||
25 | return $i['label']; | ||
26 | }, $content); | ||
27 | |||
28 | $this->assertNotContains($this->otherUserTagLabel, $tagLabels, 'There is a possible tag leak'); | ||
29 | |||
22 | return end($content); | 30 | return end($content); |
23 | } | 31 | } |
24 | 32 | ||
25 | public function testDeleteUserTag() | 33 | public function testDeleteUserTag() |
26 | { | 34 | { |
35 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | ||
36 | $entry = $this->client->getContainer() | ||
37 | ->get('doctrine.orm.entity_manager') | ||
38 | ->getRepository('WallabagCoreBundle:Entry') | ||
39 | ->findOneWithTags($this->user->getId()); | ||
40 | |||
41 | $entry = $entry[0]; | ||
42 | |||
27 | $tagLabel = 'tagtest'; | 43 | $tagLabel = 'tagtest'; |
28 | $tag = new Tag(); | 44 | $tag = new Tag(); |
29 | $tag->setLabel($tagLabel); | 45 | $tag->setLabel($tagLabel); |
30 | |||
31 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | ||
32 | $em->persist($tag); | 46 | $em->persist($tag); |
47 | |||
48 | $entry->addTag($tag); | ||
49 | |||
50 | $em->persist($entry); | ||
33 | $em->flush(); | 51 | $em->flush(); |
34 | $em->clear(); | 52 | $em->clear(); |
35 | 53 | ||
@@ -53,6 +71,16 @@ class TagRestControllerTest extends WallabagApiTestCase | |||
53 | $this->assertNull($tag, $tagLabel . ' was removed because it begun an orphan tag'); | 71 | $this->assertNull($tag, $tagLabel . ' was removed because it begun an orphan tag'); |
54 | } | 72 | } |
55 | 73 | ||
74 | public function testDeleteOtherUserTag() | ||
75 | { | ||
76 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | ||
77 | $tag = $em->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($this->otherUserTagLabel); | ||
78 | |||
79 | $this->client->request('DELETE', '/api/tags/' . $tag->getId() . '.json'); | ||
80 | |||
81 | $this->assertSame(404, $this->client->getResponse()->getStatusCode()); | ||
82 | } | ||
83 | |||
56 | public function dataForDeletingTagByLabel() | 84 | public function dataForDeletingTagByLabel() |
57 | { | 85 | { |
58 | return [ | 86 | return [ |
@@ -112,6 +140,13 @@ class TagRestControllerTest extends WallabagApiTestCase | |||
112 | $this->assertSame(404, $this->client->getResponse()->getStatusCode()); | 140 | $this->assertSame(404, $this->client->getResponse()->getStatusCode()); |
113 | } | 141 | } |
114 | 142 | ||
143 | public function testDeleteTagByLabelOtherUser() | ||
144 | { | ||
145 | $this->client->request('DELETE', '/api/tag/label.json', ['tag' => $this->otherUserTagLabel]); | ||
146 | |||
147 | $this->assertSame(404, $this->client->getResponse()->getStatusCode()); | ||
148 | } | ||
149 | |||
115 | /** | 150 | /** |
116 | * @dataProvider dataForDeletingTagByLabel | 151 | * @dataProvider dataForDeletingTagByLabel |
117 | */ | 152 | */ |
@@ -180,4 +215,11 @@ class TagRestControllerTest extends WallabagApiTestCase | |||
180 | 215 | ||
181 | $this->assertSame(404, $this->client->getResponse()->getStatusCode()); | 216 | $this->assertSame(404, $this->client->getResponse()->getStatusCode()); |
182 | } | 217 | } |
218 | |||
219 | public function testDeleteTagsByLabelOtherUser() | ||
220 | { | ||
221 | $this->client->request('DELETE', '/api/tags/label.json', ['tags' => $this->otherUserTagLabel]); | ||
222 | |||
223 | $this->assertSame(404, $this->client->getResponse()->getStatusCode()); | ||
224 | } | ||
183 | } | 225 | } |
diff --git a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php index ac4d6cdc..8b49c0ae 100644 --- a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php | |||
@@ -18,4 +18,21 @@ class WallabagRestControllerTest extends WallabagApiTestCase | |||
18 | 18 | ||
19 | $this->assertSame($client->getContainer()->getParameter('wallabag_core.version'), $content); | 19 | $this->assertSame($client->getContainer()->getParameter('wallabag_core.version'), $content); |
20 | } | 20 | } |
21 | |||
22 | public function testGetInfo() | ||
23 | { | ||
24 | // create a new client instead of using $this->client to be sure client isn't authenticated | ||
25 | $client = static::createClient(); | ||
26 | $client->request('GET', '/api/info'); | ||
27 | |||
28 | $this->assertSame(200, $client->getResponse()->getStatusCode()); | ||
29 | |||
30 | $content = json_decode($client->getResponse()->getContent(), true); | ||
31 | |||
32 | $this->assertArrayHasKey('appname', $content); | ||
33 | $this->assertArrayHasKey('version', $content); | ||
34 | $this->assertArrayHasKey('allowed_registration', $content); | ||
35 | |||
36 | $this->assertSame('wallabag', $content['appname']); | ||
37 | } | ||
21 | } | 38 | } |
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index cf9f1e97..c9dbbaa3 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php | |||
@@ -1,6 +1,6 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace tests\Wallabag\CoreBundle\Controller; | 3 | namespace Tests\Wallabag\CoreBundle\Controller; |
4 | 4 | ||
5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | 5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; |
6 | use Wallabag\AnnotationBundle\Entity\Annotation; | 6 | use Wallabag\AnnotationBundle\Entity\Annotation; |
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 006ca330..005296ff 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -522,9 +522,12 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
522 | 522 | ||
523 | $crawler = $client->followRedirect(); | 523 | $crawler = $client->followRedirect(); |
524 | 524 | ||
525 | $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); | 525 | $title = $crawler->filter('div[id=article] h1')->extract(['_text']); |
526 | $this->assertGreaterThan(1, $title); | ||
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 | |
529 | $stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']); | ||
530 | $this->assertCount(1, $stats); | ||
528 | $this->assertNotContains('example.io', trim($stats[0])); | 531 | $this->assertNotContains('example.io', trim($stats[0])); |
529 | } | 532 | } |
530 | 533 | ||
@@ -1327,10 +1330,6 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1327 | 'http://www.hao123.com/shequ?__noscript__-=1', | 1330 | 'http://www.hao123.com/shequ?__noscript__-=1', |
1328 | 'zh_CN', | 1331 | 'zh_CN', |
1329 | ], | 1332 | ], |
1330 | 'ru' => [ | ||
1331 | 'https://www.kp.ru/daily/26879.7/3921982/', | ||
1332 | 'ru', | ||
1333 | ], | ||
1334 | 'pt_BR' => [ | 1333 | 'pt_BR' => [ |
1335 | 'https://politica.estadao.com.br/noticias/eleicoes,campanha-catatonica,70002491983', | 1334 | 'https://politica.estadao.com.br/noticias/eleicoes,campanha-catatonica,70002491983', |
1336 | 'pt_BR', | 1335 | 'pt_BR', |
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php index 6f3308e5..d7ce7c45 100644 --- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | |||
@@ -98,7 +98,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
98 | 98 | ||
99 | $headers = $client->getResponse()->headers; | 99 | $headers = $client->getResponse()->headers; |
100 | $this->assertSame('application/x-mobipocket-ebook', $headers->get('content-type')); | 100 | $this->assertSame('application/x-mobipocket-ebook', $headers->get('content-type')); |
101 | $this->assertSame('attachment; filename="' . preg_replace('/[^A-Za-z0-9\-]/', '', $content->getTitle()) . '.mobi"', $headers->get('content-disposition')); | 101 | $this->assertSame('attachment; filename="' . $this->getSanitizedFilename($content->getTitle()) . '.mobi"', $headers->get('content-disposition')); |
102 | $this->assertSame('binary', $headers->get('content-transfer-encoding')); | 102 | $this->assertSame('binary', $headers->get('content-transfer-encoding')); |
103 | } | 103 | } |
104 | 104 | ||
@@ -126,7 +126,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
126 | 126 | ||
127 | $headers = $client->getResponse()->headers; | 127 | $headers = $client->getResponse()->headers; |
128 | $this->assertSame('application/pdf', $headers->get('content-type')); | 128 | $this->assertSame('application/pdf', $headers->get('content-type')); |
129 | $this->assertSame('attachment; filename="Tag_entries articles.pdf"', $headers->get('content-disposition')); | 129 | $this->assertSame('attachment; filename="Tag foo bar articles.pdf"', $headers->get('content-disposition')); |
130 | $this->assertSame('binary', $headers->get('content-transfer-encoding')); | 130 | $this->assertSame('binary', $headers->get('content-transfer-encoding')); |
131 | } | 131 | } |
132 | 132 | ||
@@ -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->assertCount(\count($contentInDB) + 1, $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]); |
@@ -212,7 +212,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
212 | 212 | ||
213 | $headers = $client->getResponse()->headers; | 213 | $headers = $client->getResponse()->headers; |
214 | $this->assertSame('application/json', $headers->get('content-type')); | 214 | $this->assertSame('application/json', $headers->get('content-type')); |
215 | $this->assertSame('attachment; filename="' . $contentInDB->getTitle() . '.json"', $headers->get('content-disposition')); | 215 | $this->assertSame('attachment; filename="' . $this->getSanitizedFilename($contentInDB->getTitle()) . '.json"', $headers->get('content-disposition')); |
216 | $this->assertSame('UTF-8', $headers->get('content-transfer-encoding')); | 216 | $this->assertSame('UTF-8', $headers->get('content-transfer-encoding')); |
217 | 217 | ||
218 | $content = json_decode($client->getResponse()->getContent(), true); | 218 | $content = json_decode($client->getResponse()->getContent(), true); |
@@ -281,4 +281,9 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
281 | $this->assertNotEmpty('created_at', (string) $content->entry[0]->created_at); | 281 | $this->assertNotEmpty('created_at', (string) $content->entry[0]->created_at); |
282 | $this->assertNotEmpty('updated_at', (string) $content->entry[0]->updated_at); | 282 | $this->assertNotEmpty('updated_at', (string) $content->entry[0]->updated_at); |
283 | } | 283 | } |
284 | |||
285 | private function getSanitizedFilename($title) | ||
286 | { | ||
287 | return preg_replace('/[^A-Za-z0-9\- \']/', '', iconv('utf-8', 'us-ascii//TRANSLIT', $title)); | ||
288 | } | ||
284 | } | 289 | } |
diff --git a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php index 2af6e14f..afa90621 100644 --- a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php | |||
@@ -11,7 +11,7 @@ class RssControllerTest extends WallabagCoreTestCase | |||
11 | $doc = new \DOMDocument(); | 11 | $doc = new \DOMDocument(); |
12 | $doc->loadXML($xml); | 12 | $doc->loadXML($xml); |
13 | 13 | ||
14 | $xpath = new \DOMXpath($doc); | 14 | $xpath = new \DOMXPath($doc); |
15 | 15 | ||
16 | if (null === $nb) { | 16 | if (null === $nb) { |
17 | $this->assertGreaterThan(0, $xpath->query('//item')->length); | 17 | $this->assertGreaterThan(0, $xpath->query('//item')->length); |
diff --git a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php index 04e1a59c..29e12cbe 100644 --- a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php +++ b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php | |||
@@ -17,6 +17,9 @@ class RedirectTest extends TestCase | |||
17 | /** @var Redirect */ | 17 | /** @var Redirect */ |
18 | private $redirect; | 18 | private $redirect; |
19 | 19 | ||
20 | /** @var UsernamePasswordToken */ | ||
21 | private $token; | ||
22 | |||
20 | public function setUp() | 23 | public function setUp() |
21 | { | 24 | { |
22 | $this->routerMock = $this->getMockBuilder('Symfony\Component\Routing\Router') | 25 | $this->routerMock = $this->getMockBuilder('Symfony\Component\Routing\Router') |
diff --git a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php b/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php index b044a700..800af5c9 100644 --- a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php +++ b/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php | |||
@@ -1,6 +1,6 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace Tests\Wallabag\CoreBundle\Command; | 3 | namespace Tests\Wallabag\CoreBundle\ParamConverter; |
4 | 4 | ||
5 | use PHPUnit\Framework\TestCase; | 5 | use PHPUnit\Framework\TestCase; |
6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; | 6 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; |
diff --git a/tests/Wallabag/CoreBundle/Tools/UtilsTest.php b/tests/Wallabag/CoreBundle/Tools/UtilsTest.php index 952d076d..c6ed74f0 100644 --- a/tests/Wallabag/CoreBundle/Tools/UtilsTest.php +++ b/tests/Wallabag/CoreBundle/Tools/UtilsTest.php | |||
@@ -11,9 +11,9 @@ class UtilsTest extends TestCase | |||
11 | /** | 11 | /** |
12 | * @dataProvider examples | 12 | * @dataProvider examples |
13 | */ | 13 | */ |
14 | public function testCorrectWordsCountForDifferentLanguages($text, $expectedCount) | 14 | public function testCorrectWordsCountForDifferentLanguages($filename, $text, $expectedCount) |
15 | { | 15 | { |
16 | static::assertSame((float) $expectedCount, Utils::getReadingTime($text)); | 16 | static::assertSame((float) $expectedCount, Utils::getReadingTime($text), 'Reading time for: ' . $filename); |
17 | } | 17 | } |
18 | 18 | ||
19 | public function examples() | 19 | public function examples() |
@@ -21,7 +21,17 @@ class UtilsTest extends TestCase | |||
21 | $examples = []; | 21 | $examples = []; |
22 | $finder = (new Finder())->in(__DIR__ . '/samples'); | 22 | $finder = (new Finder())->in(__DIR__ . '/samples'); |
23 | foreach ($finder->getIterator() as $file) { | 23 | foreach ($finder->getIterator() as $file) { |
24 | $examples[] = [$file->getContents(), 1]; | 24 | preg_match('/-----CONTENT-----\s*(.*?)\s*-----READING_TIME-----\s*(.*)/sx', $file->getContents(), $match); |
25 | |||
26 | if (3 !== \count($match)) { | ||
27 | throw new \Exception('Sample file "' . $file->getRelativePathname() . '" as wrong definition, see README.'); | ||
28 | } | ||
29 | |||
30 | $examples[] = [ | ||
31 | $file->getRelativePathname(), | ||
32 | $match[1], // content | ||
33 | $match[2], // reading time | ||
34 | ]; | ||
25 | } | 35 | } |
26 | 36 | ||
27 | return $examples; | 37 | return $examples; |
diff --git a/tests/Wallabag/CoreBundle/Tools/samples/README b/tests/Wallabag/CoreBundle/Tools/samples/README new file mode 100644 index 00000000..e8f946c0 --- /dev/null +++ b/tests/Wallabag/CoreBundle/Tools/samples/README | |||
@@ -0,0 +1,5 @@ | |||
1 | Defined language sample should use the following structure: | ||
2 | |||
3 | -----CONTENT----- | ||
4 | |||
5 | -----READING_TIME----- | ||
diff --git a/tests/Wallabag/CoreBundle/Tools/samples/chinese.txt b/tests/Wallabag/CoreBundle/Tools/samples/chinese.txt new file mode 100644 index 00000000..864603cb --- /dev/null +++ b/tests/Wallabag/CoreBundle/Tools/samples/chinese.txt | |||
@@ -0,0 +1,10 @@ | |||
1 | -----CONTENT----- | ||
2 | 职然问讲念谷月挂大报住本読能录要褐込。料士纸木陈与兴组静终図问有。今観深车相环学俳健越増职県県多券报。雪月批导掲稿家缝城间真中崩図人连。前担写治芸面毎作似水州稿注球戦頃。済方宮安目垣強入料会先呼略。計定設負財作覧経己員事田事球岡示差学。最院書模婚金回禁朝船教任分禁検理慮宿。 | ||
3 | |||
4 | 変送调指式真気交现上様女限宅复。禁业稿者普视想来木残止者済断式安。万致相领鉄再改界逮由竹式元最台変。済问活助库脳部风政京転说区変。文図化仙政常地里芸上褒前読望误记温政信土。惑育候当人万部逮重申結標番業望般。断瀬後社天打日資交献秀世覧第。補当編里身社記利件部夜中心掲大。 | ||
5 | |||
6 | 时大栗夜测署市要纯京挙化済负品。天最场情算掲放故手茨指岛然渡活民年。第纯交一特问明室试賛际者建。论铜所常縄一広気特秋提公茶可満编旅相変権。 | ||
7 | |||
8 | 兵线済来先决模入供定树希逮技鉄多连写塩。着刊禁浩歩人仕设谢争关周徒今高。十育幕桂球门载任快毎社洋着道育纸格幻末。关机高害通方纳狱社州要北相持中表。郎市真提里过何连地更重都山割周。 | ||
9 | -----READING_TIME----- | ||
10 | 1 | ||
diff --git a/tests/Wallabag/CoreBundle/Tools/samples/cyrillic.txt b/tests/Wallabag/CoreBundle/Tools/samples/cyrillic.txt index 7b904da4..90906d04 100644 --- a/tests/Wallabag/CoreBundle/Tools/samples/cyrillic.txt +++ b/tests/Wallabag/CoreBundle/Tools/samples/cyrillic.txt | |||
@@ -1,7 +1,10 @@ | |||
1 | -----CONTENT----- | ||
1 | Лорем ипсум долор сит амет, ех цум иллуд деленит, пер регионе фацилис те. Еи мел видит саепе интеллегам, яуас маиестатис цонституам яуо ат, цивибус реформиданс нецесситатибус ид яуи. Импетус тациматес пертинах ад еум. Усу еу легере бландит. | 2 | Лорем ипсум долор сит амет, ех цум иллуд деленит, пер регионе фацилис те. Еи мел видит саепе интеллегам, яуас маиестатис цонституам яуо ат, цивибус реформиданс нецесситатибус ид яуи. Импетус тациматес пертинах ад еум. Усу еу легере бландит. |
2 | 3 | ||
3 | Ан меа тритани иуварет, иллум сцаевола легендос ат меа, дебитис импедит нусяуам ест ад. Не маиорум молестие цотидиеяуе вис. Иисяуе цонцлудатуряуе меи еу, татион цонсецтетуер еи про. Либер риденс ид хас, ид цонсул сенсерит пертинациа меа. Фацер молестиае цомпрехенсам ад еум, ин хис апеириан вивендум. Яуи аудире епицуреи иудицабит ат, веро хабео вертерем ад иус. Бонорум плацерат ин вис, сеа но оцурререт принципес интерессет, хас ет дицерет диспутандо. | 4 | Ан меа тритани иуварет, иллум сцаевола легендос ат меа, дебитис импедит нусяуам ест ад. Не маиорум молестие цотидиеяуе вис. Иисяуе цонцлудатуряуе меи еу, татион цонсецтетуер еи про. Либер риденс ид хас, ид цонсул сенсерит пертинациа меа. Фацер молестиае цомпрехенсам ад еум, ин хис апеириан вивендум. Яуи аудире епицуреи иудицабит ат, веро хабео вертерем ад иус. Бонорум плацерат ин вис, сеа но оцурререт принципес интерессет, хас ет дицерет диспутандо. |
4 | 5 | ||
5 | Яуо цу цлита оцурререт. Сонет менандри ин сеа. Еум те нонумы вертерем. Вирис еяуидем фацилиси ет вим, делицата интеллегат иус ин. Ид дицат суммо витае вел, алияуип делецтус те дуо, цу вих хинц дуис видиссе. Нец цу фацилис урбанитас, алиа инсоленс ассуеверит при ут. | 6 | Яуо цу цлита оцурререт. Сонет менандри ин сеа. Еум те нонумы вертерем. Вирис еяуидем фацилиси ет вим, делицата интеллегат иус ин. Ид дицат суммо витае вел, алияуип делецтус те дуо, цу вих хинц дуис видиссе. Нец цу фацилис урбанитас, алиа инсоленс ассуеверит при ут. |
6 | 7 | ||
7 | Яуаеяуе абхорреант инцоррупте не сеа, еу еирмод ерудити вих. Вел оптион тритани цоррумпит те. Поссе сусципит губергрен ут мел, ет еос ириуре менандри еффициенди. Те сале нулла цонсецтетуер сеа, меа не прима алиенум еффициантур. При ет воцибус реформиданс, темпор албуциус сед ан. Еи утрояуе волумус иус, атяуи цонгуе но меи. \ No newline at end of file | 8 | Яуаеяуе абхорреант инцоррупте не сеа, еу еирмод ерудити вих. Вел оптион тритани цоррумпит те. Поссе сусципит губергрен ут мел, ет еос ириуре менандри еффициенди. Те сале нулла цонсецтетуер сеа, меа не прима алиенум еффициантур. При ет воцибус реформиданс, темпор албуциус сед ан. Еи утрояуе волумус иус, атяуи цонгуе но меи. |
9 | -----READING_TIME----- | ||
10 | 1 | ||
diff --git a/tests/Wallabag/CoreBundle/Tools/samples/greek.txt b/tests/Wallabag/CoreBundle/Tools/samples/greek.txt index 59f15b8b..f8ade0d7 100644 --- a/tests/Wallabag/CoreBundle/Tools/samples/greek.txt +++ b/tests/Wallabag/CoreBundle/Tools/samples/greek.txt | |||
@@ -1,3 +1,4 @@ | |||
1 | -----CONTENT----- | ||
1 | Λορεμ ιπσθμ δολορ σιτ αμετ, ηασ νο θταμθρ qθαεqθε ρεπρεηενδθντ. Ναμ λατινε προμπτα qθαερενδθμ ιδ. Νεc ει φαcερ cονcλθδατθρqθε, vολθπτθα vολθπταρια εφφιcιενδι αδ προ, νε σεα ασσεντιορ δεφινιεβασ. Μεα αγαμ ειθσ δολορε ετ, ηισ ει cορπορα περφεcτο. Vιξ cιβο δελενιτ νε, jθστο ριδενσ οπορτερε σεδ ιδ. | 2 | Λορεμ ιπσθμ δολορ σιτ αμετ, ηασ νο θταμθρ qθαεqθε ρεπρεηενδθντ. Ναμ λατινε προμπτα qθαερενδθμ ιδ. Νεc ει φαcερ cονcλθδατθρqθε, vολθπτθα vολθπταρια εφφιcιενδι αδ προ, νε σεα ασσεντιορ δεφινιεβασ. Μεα αγαμ ειθσ δολορε ετ, ηισ ει cορπορα περφεcτο. Vιξ cιβο δελενιτ νε, jθστο ριδενσ οπορτερε σεδ ιδ. |
2 | 3 | ||
3 | Ηισ νισλ ιθvαρετ γθβεργρεν εξ. Εθμ ιμπεδιτ δετραξιτ ινιμιcθσ ατ, αλια βλανδιτ δθο εα, μεα ιλλθδ επιcθρι cονσετετθρ αδ. Ιλλθδ γραεcε δελενιτι ηισ νο. Νεc ιδ ριδενσ εθισμοδ περιcθλισ, vισ αδ λαβοραμθσ περσεcθτι. Ιθσ εα λθπτατθμ αλιqθανδο δισπθτανδο. | 4 | Ηισ νισλ ιθvαρετ γθβεργρεν εξ. Εθμ ιμπεδιτ δετραξιτ ινιμιcθσ ατ, αλια βλανδιτ δθο εα, μεα ιλλθδ επιcθρι cονσετετθρ αδ. Ιλλθδ γραεcε δελενιτι ηισ νο. Νεc ιδ ριδενσ εθισμοδ περιcθλισ, vισ αδ λαβοραμθσ περσεcθτι. Ιθσ εα λθπτατθμ αλιqθανδο δισπθτανδο. |
@@ -6,4 +7,6 @@ | |||
6 | 7 | ||
7 | Cθ σεδ αλβθcιθσ ποστθλαντ. Vιξ ιδ ηομερο περcιπιτ cονcεπταμ. Ιν vιμ λιβρισ vιδερερ, εξ vισ αλιι ερρορ. Vιξ λοβορτισ ασσεντιορ cοντεντιονεσ τε, νε ηασ δεcορε περcιπιτθρ. Εστ εξ δισπθτατιονι δεφινιτιονεμ, qθοδ πηαεδρθμ προ εθ, εξ ηασ ιντεγρε ελιγενδι cονσεcτετθερ. | 8 | Cθ σεδ αλβθcιθσ ποστθλαντ. Vιξ ιδ ηομερο περcιπιτ cονcεπταμ. Ιν vιμ λιβρισ vιδερερ, εξ vισ αλιι ερρορ. Vιξ λοβορτισ ασσεντιορ cοντεντιονεσ τε, νε ηασ δεcορε περcιπιτθρ. Εστ εξ δισπθτατιονι δεφινιτιονεμ, qθοδ πηαεδρθμ προ εθ, εξ ηασ ιντεγρε ελιγενδι cονσεcτετθερ. |
8 | 9 | ||
9 | Ιθσ μολλισ ειρμοδ νο, vιξ νοστρθμ cονσετετθρ ει. Ιθδιcο vερτερεμ λθcιλιθσ qθι τε, νε προμπτα θτροqθε αccομμοδαρε περ. Φαcετε μανδαμθσ ηασ εξ, λιβερ δεβετ εθμ εξ, vιξ ιδ διcερετ σιγνιφερθμqθε. Εθ vιξ vοcεντ. \ No newline at end of file | 10 | Ιθσ μολλισ ειρμοδ νο, vιξ νοστρθμ cονσετετθρ ει. Ιθδιcο vερτερεμ λθcιλιθσ qθι τε, νε προμπτα θτροqθε αccομμοδαρε περ. Φαcετε μανδαμθσ ηασ εξ, λιβερ δεβετ εθμ εξ, vιξ ιδ διcερετ σιγνιφερθμqθε. Εθ vιξ vοcεντ. |
11 | -----READING_TIME----- | ||
12 | 1 | ||
diff --git a/tests/Wallabag/CoreBundle/Tools/samples/japanese.txt b/tests/Wallabag/CoreBundle/Tools/samples/japanese.txt new file mode 100644 index 00000000..013a8d74 --- /dev/null +++ b/tests/Wallabag/CoreBundle/Tools/samples/japanese.txt | |||
@@ -0,0 +1,10 @@ | |||
1 | -----CONTENT----- | ||
2 | 聞7配なク時初かきぴ触整ヨ国鴨覧女ミ将増3部ゅ見荷や言企まげやラ千第ロル企族リた期寄け。戦ト理載コミチヒ芸面だ会入テヒロソ一期ナトヒ試鮮せお天出並ぞる体森ヘツノ決市ね地各ナク強町ず前目とまなを活直オ携握湯りよ。 | ||
3 | |||
4 | 流ムワ作大禁ヒフ断日ヱ断千ね消諸もとぐろ中勧リ配年リ文7茅ろへりめ辺渡フ三負安ぼ国撮ライム以逃めじット州67棋うきゃ。催キケ者乗フヒソツ染64崎ク捉示よぴふら道世へび属品おく西捕ニレ交重イフ式買散ル展五めづっイ鎧属ざごび数開キハツ聞続表クシタ補球ソウ禁源託ひれも。 | ||
5 | |||
6 | 季手ッがふ挙思メ勢1使すけねげ日熱争らあふか位義エコ望桑安く決管ーひ広間キヱ皇北ょはこ養山ミ放見負さぞて故携訃畑港ひわン。著支にふみ意豊ラだ球監トクユ馬惨が抱審リヒ労厚ゅぽひ継貸ミノ果疑文キヤ闘府兼ユカシト多不っあ財責エ速訴径猶げすぽ。 | ||
7 | |||
8 | 了摘見いぶころ会料へゆぱ法利コツハリ統財千りイ伝年りぜ提社ロ片追ごー合作イカシニ感山よち真器敗香レれさ。視シ探大イ令69真ケトヱ便都ケホワナ境号ヱカオハ一助む関念ろんび幼脚要だ客投ヱハイ針教ヒノウラ階担うスりね袖陸ょげけ同講ノ料全ヤ催宮補ゆ徳就画圧愛め。 | ||
9 | -----READING_TIME----- | ||
10 | 1 | ||
diff --git a/tests/Wallabag/CoreBundle/Tools/samples/korean.txt b/tests/Wallabag/CoreBundle/Tools/samples/korean.txt new file mode 100644 index 00000000..e3ef2af6 --- /dev/null +++ b/tests/Wallabag/CoreBundle/Tools/samples/korean.txt | |||
@@ -0,0 +1,10 @@ | |||
1 | -----CONTENT----- | ||
2 | 국군은 국가의 안전보장과 국토방위의 신성한 의무를 수행함을 사명으로 하며, 대통령이 임시회의 집회를 요구할 때에는 기간과 집회요구의 이유를 명시하여야 한다. 정당의 목적이나 활동이 민주적 기본질서에 위배될 때에는 정부는 헌법재판소에 그 해산을 제소할 수 있고. 감사위원은 원장의 제청으로 대통령이 임명하고. | ||
3 | |||
4 | 대한민국의 주권은 국민에게 있고, 국회는 국민의 보통·평등·직접·비밀선거에 의하여 선출된 국회의원으로 구성한다. 국가는 농업 및 어업을 보호·육성하기 위하여 농·어촌종합개발과 그 지원등 필요한 계획을 수립·시행하여야 한다. 대통령의 임기연장 또는 중임변경을 위한 헌법개정은 그 헌법개정 제안 당시의 대통령에 대하여는 효력이 없다. | ||
5 | |||
6 | 국회가 재적의원 과반수의 찬성으로 계엄의 해제를 요구한 때에는 대통령은 이를 해제하여야 한다, 선거에 관한 경비는 법률이 정하는 경우를 제외하고는 정당 또는 후보자에게 부담시킬 수 없다. 그 정치적 중립성은 준수된다. 헌법개정안은 국회가 의결한 후 30일 이내에 국민투표에 붙여 국회의원선거권자 과반수의 투표와 투표자 과반수의 찬성을 얻어야 한다. | ||
7 | |||
8 | 내부규율과 사무처리에 관한 규칙을 제정할 수 있다. 대통령에 대한 탄핵소추는 국회재적의원 과반수의 발의와 국회재적의원 3분의 2 이상의 찬성이 있어야 한다. 대통령은 국가의 원수이며. 대통령이 궐위된 때 또는 대통령 당선자가 사망하거나 판결 기타의 사유로 그 자격을 상실한 때에는 60일 이내에 후임자를 선거한다. | ||
9 | -----READING_TIME----- | ||
10 | 2 | ||
diff --git a/tests/Wallabag/CoreBundle/Tools/samples/latin.txt b/tests/Wallabag/CoreBundle/Tools/samples/latin.txt index 605cc40e..27988597 100644 --- a/tests/Wallabag/CoreBundle/Tools/samples/latin.txt +++ b/tests/Wallabag/CoreBundle/Tools/samples/latin.txt | |||
@@ -1,3 +1,4 @@ | |||
1 | -----CONTENT----- | ||
1 | Lorem ipsum dolor sit amet, pro vivendo oporteat pertinacia ei. Vim fabellas molestiae cu, vel nibh legimus ea, in qui atomorum democritum. Ius ne agam soluta ignota, his sale aperiri complectitur te, omnis volumus accusam an eos. Ut mentitum appetere mel, minim temporibus eloquentiam sea ea. | 2 | Lorem ipsum dolor sit amet, pro vivendo oporteat pertinacia ei. Vim fabellas molestiae cu, vel nibh legimus ea, in qui atomorum democritum. Ius ne agam soluta ignota, his sale aperiri complectitur te, omnis volumus accusam an eos. Ut mentitum appetere mel, minim temporibus eloquentiam sea ea. |
2 | 3 | ||
3 | Tation nominati pro ad. Pri eros eloquentiam reformidans ea, et liber epicurei erroribus pro, pri patrioque repudiandae et. Cetero perfecto at eam. Eros hendrerit constituto vix at, brute aperiri adolescens pro eu. Vix lucilius consulatu ei, ullum tantas munere vel in, regione feugiat eligendi at eam. | 4 | Tation nominati pro ad. Pri eros eloquentiam reformidans ea, et liber epicurei erroribus pro, pri patrioque repudiandae et. Cetero perfecto at eam. Eros hendrerit constituto vix at, brute aperiri adolescens pro eu. Vix lucilius consulatu ei, ullum tantas munere vel in, regione feugiat eligendi at eam. |
@@ -6,4 +7,6 @@ Eam an lucilius iracundia, audire diceret facilisi his in, ex paulo pertinacia p | |||
6 | 7 | ||
7 | Nec ut quod probo eligendi, cu dico iriure aperiam vis. Augue causae abhorreant per ut, iriure repudiandae no nam, exerci equidem deleniti nam te. Et duo saperet debitis adipiscing, quo odio audiam no, ex iudico delenit propriae duo. Eu eum eros abhorreant, an tractatos expetendis est. | 8 | Nec ut quod probo eligendi, cu dico iriure aperiam vis. Augue causae abhorreant per ut, iriure repudiandae no nam, exerci equidem deleniti nam te. Et duo saperet debitis adipiscing, quo odio audiam no, ex iudico delenit propriae duo. Eu eum eros abhorreant, an tractatos expetendis est. |
8 | 9 | ||
9 | Vix. \ No newline at end of file | 10 | Vix. |
11 | -----READING_TIME----- | ||
12 | 1 | ||
diff --git a/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php b/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php index b2141c04..b7f6192d 100644 --- a/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php +++ b/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php | |||
@@ -1,6 +1,6 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace Tests\Wallabag\ImportBundle\Consumer\AMQP; | 3 | namespace Tests\Wallabag\ImportBundle\Consumer; |
4 | 4 | ||
5 | use PhpAmqpLib\Message\AMQPMessage; | 5 | use PhpAmqpLib\Message\AMQPMessage; |
6 | use PHPUnit\Framework\TestCase; | 6 | use PHPUnit\Framework\TestCase; |
diff --git a/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php index 61337e47..e1bd8827 100644 --- a/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php +++ b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php | |||
@@ -1,6 +1,6 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace Tests\Wallabag\ImportBundle\Consumer\AMQP; | 3 | namespace Tests\Wallabag\ImportBundle\Consumer; |
4 | 4 | ||
5 | use PHPUnit\Framework\TestCase; | 5 | use PHPUnit\Framework\TestCase; |
6 | use Wallabag\CoreBundle\Entity\Entry; | 6 | use Wallabag\CoreBundle\Entity\Entry; |
diff --git a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php index cd3e41e9..d3ffbb6d 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->assertCount(1, $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 dc5ed6d0..3e64f2e5 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->assertCount(3, $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 7390fa88..05347767 100644 --- a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php | |||
@@ -124,7 +124,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase | |||
124 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture 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'); | 125 | $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.liberation.fr is ok'); |
126 | $this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag'); | 126 | $this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag'); |
127 | $this->assertSame(1, \count($content->getTags())); | 127 | $this->assertCount(1, $content->getTags()); |
128 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 128 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
129 | 129 | ||
130 | $content = $client->getContainer() | 130 | $content = $client->getContainer() |
@@ -138,7 +138,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase | |||
138 | $this->assertContains('foot', $content->getTags()); | 138 | $this->assertContains('foot', $content->getTags()); |
139 | $this->assertContains('test_tag', $content->getTags()); | 139 | $this->assertContains('test_tag', $content->getTags()); |
140 | 140 | ||
141 | $this->assertSame(2, \count($content->getTags())); | 141 | $this->assertCount(2, $content->getTags()); |
142 | } | 142 | } |
143 | 143 | ||
144 | public function testImportInstapaperWithFileAndMarkAllAsRead() | 144 | public function testImportInstapaperWithFileAndMarkAllAsRead() |
diff --git a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php index 80819f45..15646d55 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->assertCount(3, $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 5619659a..4f2f4053 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->assertCount(1, $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 c67941a7..1f57939d 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->assertCount(2, $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 822656ba..b606e26a 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php | |||
@@ -128,7 +128,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase | |||
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->assertCount(1, $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->assertCount(3, $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/UserBundle/Controller/ManageControllerTest.php b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php index adc2cf09..f44e6fbf 100644 --- a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php +++ b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php | |||
@@ -1,6 +1,6 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace Wallabag\UserBundle\Tests\Controller; | 3 | namespace Tests\Wallabag\UserBundle\Controller; |
4 | 4 | ||
5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | 5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; |
6 | 6 | ||
diff --git a/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php b/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php index aa176068..e34e13a8 100644 --- a/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php +++ b/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php | |||
@@ -6,22 +6,6 @@ use PHPUnit\Framework\TestCase; | |||
6 | use Wallabag\UserBundle\Entity\User; | 6 | use Wallabag\UserBundle\Entity\User; |
7 | use Wallabag\UserBundle\Mailer\AuthCodeMailer; | 7 | use Wallabag\UserBundle\Mailer\AuthCodeMailer; |
8 | 8 | ||
9 | /** | ||
10 | * @see https://www.pmg.com/blog/integration-testing-swift-mailer/ | ||
11 | */ | ||
12 | final class CountableMemorySpool extends \Swift_MemorySpool implements \Countable | ||
13 | { | ||
14 | public function count() | ||
15 | { | ||
16 | return \count($this->messages); | ||
17 | } | ||
18 | |||
19 | public function getMessages() | ||
20 | { | ||
21 | return $this->messages; | ||
22 | } | ||
23 | } | ||
24 | |||
25 | class AuthCodeMailerTest extends TestCase | 9 | class AuthCodeMailerTest extends TestCase |
26 | { | 10 | { |
27 | protected $mailer; | 11 | protected $mailer; |
diff --git a/tests/Wallabag/UserBundle/Mailer/CountableMemorySpool.php b/tests/Wallabag/UserBundle/Mailer/CountableMemorySpool.php new file mode 100644 index 00000000..53f240a1 --- /dev/null +++ b/tests/Wallabag/UserBundle/Mailer/CountableMemorySpool.php | |||
@@ -0,0 +1,19 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\UserBundle\Mailer; | ||
4 | |||
5 | /** | ||
6 | * @see https://www.pmg.com/blog/integration-testing-swift-mailer/ | ||
7 | */ | ||
8 | final class CountableMemorySpool extends \Swift_MemorySpool implements \Countable | ||
9 | { | ||
10 | public function count() | ||
11 | { | ||
12 | return \count($this->messages); | ||
13 | } | ||
14 | |||
15 | public function getMessages() | ||
16 | { | ||
17 | return $this->messages; | ||
18 | } | ||
19 | } | ||