diff options
Diffstat (limited to 'tests/Wallabag')
29 files changed, 690 insertions, 210 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 0a65f9ce..bf7d373a 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -315,7 +315,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
315 | $entry = $this->client->getContainer() | 315 | $entry = $this->client->getContainer() |
316 | ->get('doctrine.orm.entity_manager') | 316 | ->get('doctrine.orm.entity_manager') |
317 | ->getRepository('WallabagCoreBundle:Entry') | 317 | ->getRepository('WallabagCoreBundle:Entry') |
318 | ->findOneByUser(1); | 318 | ->findOneByUser(1, ['id' => 'asc']); |
319 | 319 | ||
320 | if (!$entry) { | 320 | if (!$entry) { |
321 | $this->markTestSkipped('No content found in db.'); | 321 | $this->markTestSkipped('No content found in db.'); |
@@ -354,7 +354,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
354 | $this->assertEquals(false, $content['is_starred']); | 354 | $this->assertEquals(false, $content['is_starred']); |
355 | $this->assertEquals('New title for my article', $content['title']); | 355 | $this->assertEquals('New title for my article', $content['title']); |
356 | $this->assertEquals(1, $content['user_id']); | 356 | $this->assertEquals(1, $content['user_id']); |
357 | $this->assertCount(1, $content['tags']); | 357 | $this->assertCount(2, $content['tags']); |
358 | } | 358 | } |
359 | 359 | ||
360 | public function testPostSameEntry() | 360 | public function testPostSameEntry() |
@@ -373,7 +373,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
373 | $this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']); | 373 | $this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']); |
374 | $this->assertEquals(true, $content['is_archived']); | 374 | $this->assertEquals(true, $content['is_archived']); |
375 | $this->assertEquals(false, $content['is_starred']); | 375 | $this->assertEquals(false, $content['is_starred']); |
376 | $this->assertCount(2, $content['tags']); | 376 | $this->assertCount(3, $content['tags']); |
377 | } | 377 | } |
378 | 378 | ||
379 | public function testPostEntryWhenFetchContentFails() | 379 | public function testPostEntryWhenFetchContentFails() |
@@ -692,7 +692,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
692 | 692 | ||
693 | $content = json_decode($this->client->getResponse()->getContent(), true); | 693 | $content = json_decode($this->client->getResponse()->getContent(), true); |
694 | 694 | ||
695 | $this->assertEquals(true, $content['exists']); | 695 | $this->assertEquals(2, $content['exists']); |
696 | } | 696 | } |
697 | 697 | ||
698 | public function testGetEntriesExistsWithManyUrls() | 698 | public function testGetEntriesExistsWithManyUrls() |
@@ -707,7 +707,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
707 | 707 | ||
708 | $this->assertArrayHasKey($url1, $content); | 708 | $this->assertArrayHasKey($url1, $content); |
709 | $this->assertArrayHasKey($url2, $content); | 709 | $this->assertArrayHasKey($url2, $content); |
710 | $this->assertEquals(true, $content[$url1]); | 710 | $this->assertEquals(2, $content[$url1]); |
711 | $this->assertEquals(false, $content[$url2]); | 711 | $this->assertEquals(false, $content[$url2]); |
712 | } | 712 | } |
713 | 713 | ||
@@ -764,4 +764,120 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
764 | 764 | ||
765 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); | 765 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
766 | } | 766 | } |
767 | |||
768 | public function testPostEntriesTagsListAction() | ||
769 | { | ||
770 | $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') | ||
771 | ->getRepository('WallabagCoreBundle:Entry') | ||
772 | ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); | ||
773 | |||
774 | $tags = $entry->getTags(); | ||
775 | |||
776 | $this->assertCount(2, $tags); | ||
777 | |||
778 | $list = [ | ||
779 | [ | ||
780 | 'url' => 'http://0.0.0.0/entry4', | ||
781 | 'tags' => 'new tag 1, new tag 2', | ||
782 | ], | ||
783 | ]; | ||
784 | |||
785 | $this->client->request('POST', '/api/entries/tags/lists?list='.json_encode($list)); | ||
786 | |||
787 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
788 | |||
789 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
790 | |||
791 | $this->assertInternalType('int', $content[0]['entry']); | ||
792 | $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']); | ||
793 | |||
794 | $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') | ||
795 | ->getRepository('WallabagCoreBundle:Entry') | ||
796 | ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); | ||
797 | |||
798 | $tags = $entry->getTags(); | ||
799 | $this->assertCount(4, $tags); | ||
800 | } | ||
801 | |||
802 | public function testDeleteEntriesTagsListAction() | ||
803 | { | ||
804 | $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') | ||
805 | ->getRepository('WallabagCoreBundle:Entry') | ||
806 | ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); | ||
807 | |||
808 | $tags = $entry->getTags(); | ||
809 | |||
810 | $this->assertCount(4, $tags); | ||
811 | |||
812 | $list = [ | ||
813 | [ | ||
814 | 'url' => 'http://0.0.0.0/entry4', | ||
815 | 'tags' => 'new tag 1, new tag 2', | ||
816 | ], | ||
817 | ]; | ||
818 | |||
819 | $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list)); | ||
820 | } | ||
821 | |||
822 | public function testPostEntriesListAction() | ||
823 | { | ||
824 | $list = [ | ||
825 | 'http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', | ||
826 | 'http://0.0.0.0/entry2', | ||
827 | ]; | ||
828 | |||
829 | $this->client->request('POST', '/api/entries/lists?urls='.json_encode($list)); | ||
830 | |||
831 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
832 | |||
833 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
834 | |||
835 | $this->assertInternalType('int', $content[0]['entry']); | ||
836 | $this->assertEquals('http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', $content[0]['url']); | ||
837 | |||
838 | $this->assertInternalType('int', $content[1]['entry']); | ||
839 | $this->assertEquals('http://0.0.0.0/entry2', $content[1]['url']); | ||
840 | } | ||
841 | |||
842 | public function testDeleteEntriesListAction() | ||
843 | { | ||
844 | $list = [ | ||
845 | 'http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', | ||
846 | 'http://0.0.0.0/entry3', | ||
847 | ]; | ||
848 | |||
849 | $this->client->request('DELETE', '/api/entries/list?urls='.json_encode($list)); | ||
850 | |||
851 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
852 | |||
853 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
854 | |||
855 | $this->assertTrue($content[0]['entry']); | ||
856 | $this->assertEquals('http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', $content[0]['url']); | ||
857 | |||
858 | $this->assertFalse($content[1]['entry']); | ||
859 | $this->assertEquals('http://0.0.0.0/entry3', $content[1]['url']); | ||
860 | } | ||
861 | |||
862 | public function testLimitBulkAction() | ||
863 | { | ||
864 | $list = [ | ||
865 | 'http://0.0.0.0/entry1', | ||
866 | 'http://0.0.0.0/entry1', | ||
867 | 'http://0.0.0.0/entry1', | ||
868 | 'http://0.0.0.0/entry1', | ||
869 | 'http://0.0.0.0/entry1', | ||
870 | 'http://0.0.0.0/entry1', | ||
871 | 'http://0.0.0.0/entry1', | ||
872 | 'http://0.0.0.0/entry1', | ||
873 | 'http://0.0.0.0/entry1', | ||
874 | 'http://0.0.0.0/entry1', | ||
875 | 'http://0.0.0.0/entry1', | ||
876 | ]; | ||
877 | |||
878 | $this->client->request('POST', '/api/entries/lists?urls='.json_encode($list)); | ||
879 | |||
880 | $this->assertEquals(400, $this->client->getResponse()->getStatusCode()); | ||
881 | $this->assertContains('API limit reached', $this->client->getResponse()->getContent()); | ||
882 | } | ||
767 | } | 883 | } |
diff --git a/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php index bde5251f..90b132eb 100644 --- a/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php | |||
@@ -54,7 +54,18 @@ class TagRestControllerTest extends WallabagApiTestCase | |||
54 | $this->assertNull($tag, $tagName.' was removed because it begun an orphan tag'); | 54 | $this->assertNull($tag, $tagName.' was removed because it begun an orphan tag'); |
55 | } | 55 | } |
56 | 56 | ||
57 | public function testDeleteTagByLabel() | 57 | public function dataForDeletingTagByLabel() |
58 | { | ||
59 | return [ | ||
60 | 'by_query' => [true], | ||
61 | 'by_body' => [false], | ||
62 | ]; | ||
63 | } | ||
64 | |||
65 | /** | ||
66 | * @dataProvider dataForDeletingTagByLabel | ||
67 | */ | ||
68 | public function testDeleteTagByLabel($useQueryString) | ||
58 | { | 69 | { |
59 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | 70 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); |
60 | $entry = $this->client->getContainer() | 71 | $entry = $this->client->getContainer() |
@@ -73,7 +84,11 @@ class TagRestControllerTest extends WallabagApiTestCase | |||
73 | $em->persist($entry); | 84 | $em->persist($entry); |
74 | $em->flush(); | 85 | $em->flush(); |
75 | 86 | ||
76 | $this->client->request('DELETE', '/api/tag/label.json', ['tag' => $tag->getLabel()]); | 87 | if ($useQueryString) { |
88 | $this->client->request('DELETE', '/api/tag/label.json?tag='.$tag->getLabel()); | ||
89 | } else { | ||
90 | $this->client->request('DELETE', '/api/tag/label.json', ['tag' => $tag->getLabel()]); | ||
91 | } | ||
77 | 92 | ||
78 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | 93 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); |
79 | 94 | ||
@@ -98,7 +113,10 @@ class TagRestControllerTest extends WallabagApiTestCase | |||
98 | $this->assertEquals(404, $this->client->getResponse()->getStatusCode()); | 113 | $this->assertEquals(404, $this->client->getResponse()->getStatusCode()); |
99 | } | 114 | } |
100 | 115 | ||
101 | public function testDeleteTagsByLabel() | 116 | /** |
117 | * @dataProvider dataForDeletingTagByLabel | ||
118 | */ | ||
119 | public function testDeleteTagsByLabel($useQueryString) | ||
102 | { | 120 | { |
103 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | 121 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); |
104 | $entry = $this->client->getContainer() | 122 | $entry = $this->client->getContainer() |
@@ -122,7 +140,11 @@ class TagRestControllerTest extends WallabagApiTestCase | |||
122 | $em->persist($entry); | 140 | $em->persist($entry); |
123 | $em->flush(); | 141 | $em->flush(); |
124 | 142 | ||
125 | $this->client->request('DELETE', '/api/tags/label.json', ['tags' => $tag->getLabel().','.$tag2->getLabel()]); | 143 | if ($useQueryString) { |
144 | $this->client->request('DELETE', '/api/tags/label.json?tags='.$tag->getLabel().','.$tag2->getLabel()); | ||
145 | } else { | ||
146 | $this->client->request('DELETE', '/api/tags/label.json', ['tags' => $tag->getLabel().','.$tag2->getLabel()]); | ||
147 | } | ||
126 | 148 | ||
127 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | 149 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); |
128 | 150 | ||
diff --git a/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php b/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php new file mode 100644 index 00000000..e6e57f30 --- /dev/null +++ b/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php | |||
@@ -0,0 +1,108 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\CoreBundle\Command; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
6 | use Symfony\Component\Console\Tester\CommandTester; | ||
7 | use Wallabag\CoreBundle\Command\CleanDuplicatesCommand; | ||
8 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | ||
9 | use Wallabag\CoreBundle\Entity\Entry; | ||
10 | |||
11 | class CleanDuplicatesCommandTest extends WallabagCoreTestCase | ||
12 | { | ||
13 | public function testRunCleanDuplicates() | ||
14 | { | ||
15 | $application = new Application($this->getClient()->getKernel()); | ||
16 | $application->add(new CleanDuplicatesCommand()); | ||
17 | |||
18 | $command = $application->find('wallabag:clean-duplicates'); | ||
19 | |||
20 | $tester = new CommandTester($command); | ||
21 | $tester->execute([ | ||
22 | 'command' => $command->getName(), | ||
23 | ]); | ||
24 | |||
25 | $this->assertContains('Cleaning through 3 user accounts', $tester->getDisplay()); | ||
26 | $this->assertContains('Finished cleaning. 0 duplicates found in total', $tester->getDisplay()); | ||
27 | } | ||
28 | |||
29 | public function testRunCleanDuplicatesCommandWithBadUsername() | ||
30 | { | ||
31 | $application = new Application($this->getClient()->getKernel()); | ||
32 | $application->add(new CleanDuplicatesCommand()); | ||
33 | |||
34 | $command = $application->find('wallabag:clean-duplicates'); | ||
35 | |||
36 | $tester = new CommandTester($command); | ||
37 | $tester->execute([ | ||
38 | 'command' => $command->getName(), | ||
39 | 'username' => 'unknown', | ||
40 | ]); | ||
41 | |||
42 | $this->assertContains('User "unknown" not found', $tester->getDisplay()); | ||
43 | } | ||
44 | |||
45 | public function testRunCleanDuplicatesCommandForUser() | ||
46 | { | ||
47 | $application = new Application($this->getClient()->getKernel()); | ||
48 | $application->add(new CleanDuplicatesCommand()); | ||
49 | |||
50 | $command = $application->find('wallabag:clean-duplicates'); | ||
51 | |||
52 | $tester = new CommandTester($command); | ||
53 | $tester->execute([ | ||
54 | 'command' => $command->getName(), | ||
55 | 'username' => 'admin', | ||
56 | ]); | ||
57 | |||
58 | $this->assertContains('Cleaned 0 duplicates for user admin', $tester->getDisplay()); | ||
59 | } | ||
60 | |||
61 | public function testDuplicate() | ||
62 | { | ||
63 | $url = 'http://www.lemonde.fr/sport/visuel/2017/05/05/rondelle-prison-blanchissage-comprendre-le-hockey-sur-glace_5122587_3242.html'; | ||
64 | $client = $this->getClient(); | ||
65 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | ||
66 | |||
67 | $this->logInAs('admin'); | ||
68 | |||
69 | $nbEntries = $em->getRepository('WallabagCoreBundle:Entry')->findAllByUrlAndUserId($url, $this->getLoggedInUserId()); | ||
70 | $this->assertCount(0, $nbEntries); | ||
71 | |||
72 | $user = $em->getRepository('WallabagUserBundle:User')->findOneById($this->getLoggedInUserId()); | ||
73 | |||
74 | $entry1 = new Entry($user); | ||
75 | $entry1->setUrl($url); | ||
76 | |||
77 | $entry2 = new Entry($user); | ||
78 | $entry2->setUrl($url); | ||
79 | |||
80 | $em->persist($entry1); | ||
81 | $em->persist($entry2); | ||
82 | |||
83 | $em->flush(); | ||
84 | |||
85 | $nbEntries = $em->getRepository('WallabagCoreBundle:Entry')->findAllByUrlAndUserId($url, $this->getLoggedInUserId()); | ||
86 | $this->assertCount(2, $nbEntries); | ||
87 | |||
88 | $application = new Application($this->getClient()->getKernel()); | ||
89 | $application->add(new CleanDuplicatesCommand()); | ||
90 | |||
91 | $command = $application->find('wallabag:clean-duplicates'); | ||
92 | |||
93 | $tester = new CommandTester($command); | ||
94 | $tester->execute([ | ||
95 | 'command' => $command->getName(), | ||
96 | 'username' => 'admin', | ||
97 | ]); | ||
98 | |||
99 | $this->assertContains('Cleaned 1 duplicates for user admin', $tester->getDisplay()); | ||
100 | |||
101 | $nbEntries = $em->getRepository('WallabagCoreBundle:Entry')->findAllByUrlAndUserId($url, $this->getLoggedInUserId()); | ||
102 | $this->assertCount(1, $nbEntries); | ||
103 | |||
104 | $query = $em->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\Entry e WHERE e.url = :url'); | ||
105 | $query->setParameter('url', $url); | ||
106 | $query->execute(); | ||
107 | } | ||
108 | } | ||
diff --git a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php index 6798c5d7..b21f3318 100644 --- a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php | |||
@@ -70,7 +70,7 @@ class ExportCommandTest extends WallabagCoreTestCase | |||
70 | $tester->execute([ | 70 | $tester->execute([ |
71 | 'command' => $command->getName(), | 71 | 'command' => $command->getName(), |
72 | 'username' => 'admin', | 72 | 'username' => 'admin', |
73 | 'filepath' => 'specialexport.json' | 73 | 'filepath' => 'specialexport.json', |
74 | ]); | 74 | ]); |
75 | 75 | ||
76 | $this->assertFileExists('specialexport.json'); | 76 | $this->assertFileExists('specialexport.json'); |
diff --git a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php index 1bfd41d5..122a87d4 100644 --- a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php | |||
@@ -87,6 +87,7 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
87 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 87 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
88 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 88 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
89 | $this->assertContains('Config setup.', $tester->getDisplay()); | 89 | $this->assertContains('Config setup.', $tester->getDisplay()); |
90 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
90 | } | 91 | } |
91 | 92 | ||
92 | public function testRunInstallCommandWithReset() | 93 | public function testRunInstallCommandWithReset() |
@@ -115,12 +116,13 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
115 | 116 | ||
116 | $this->assertContains('Checking system requirements.', $tester->getDisplay()); | 117 | $this->assertContains('Checking system requirements.', $tester->getDisplay()); |
117 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 118 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
118 | $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay()); | 119 | $this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay()); |
119 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 120 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
120 | $this->assertContains('Config setup.', $tester->getDisplay()); | 121 | $this->assertContains('Config setup.', $tester->getDisplay()); |
122 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
121 | 123 | ||
122 | // we force to reset everything | 124 | // we force to reset everything |
123 | $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay()); | 125 | $this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay()); |
124 | } | 126 | } |
125 | 127 | ||
126 | public function testRunInstallCommandWithDatabaseRemoved() | 128 | public function testRunInstallCommandWithDatabaseRemoved() |
@@ -168,6 +170,7 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
168 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 170 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
169 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 171 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
170 | $this->assertContains('Config setup.', $tester->getDisplay()); | 172 | $this->assertContains('Config setup.', $tester->getDisplay()); |
173 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
171 | 174 | ||
172 | // the current database doesn't already exist | 175 | // the current database doesn't already exist |
173 | $this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay()); | 176 | $this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay()); |
@@ -205,8 +208,9 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
205 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 208 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
206 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 209 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
207 | $this->assertContains('Config setup.', $tester->getDisplay()); | 210 | $this->assertContains('Config setup.', $tester->getDisplay()); |
211 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
208 | 212 | ||
209 | $this->assertContains('Droping schema and creating schema', $tester->getDisplay()); | 213 | $this->assertContains('Dropping schema and creating schema', $tester->getDisplay()); |
210 | } | 214 | } |
211 | 215 | ||
212 | public function testRunInstallCommandChooseNothing() | 216 | public function testRunInstallCommandChooseNothing() |
@@ -259,6 +263,7 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
259 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 263 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
260 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 264 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
261 | $this->assertContains('Config setup.', $tester->getDisplay()); | 265 | $this->assertContains('Config setup.', $tester->getDisplay()); |
266 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
262 | 267 | ||
263 | $this->assertContains('Creating schema', $tester->getDisplay()); | 268 | $this->assertContains('Creating schema', $tester->getDisplay()); |
264 | } | 269 | } |
@@ -291,5 +296,6 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
291 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 296 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
292 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 297 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
293 | $this->assertContains('Config setup.', $tester->getDisplay()); | 298 | $this->assertContains('Config setup.', $tester->getDisplay()); |
299 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
294 | } | 300 | } |
295 | } | 301 | } |
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index beb0598a..35888f16 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php | |||
@@ -798,11 +798,87 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
798 | 798 | ||
799 | $entryReset = $em | 799 | $entryReset = $em |
800 | ->getRepository('WallabagCoreBundle:Entry') | 800 | ->getRepository('WallabagCoreBundle:Entry') |
801 | ->countAllEntriesByUsername($user->getId()); | 801 | ->countAllEntriesByUser($user->getId()); |
802 | 802 | ||
803 | $this->assertEquals(0, $entryReset, 'Entries were reset'); | 803 | $this->assertEquals(0, $entryReset, 'Entries were reset'); |
804 | } | 804 | } |
805 | 805 | ||
806 | public function testResetArchivedEntries() | ||
807 | { | ||
808 | $this->logInAs('empty'); | ||
809 | $client = $this->getClient(); | ||
810 | |||
811 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | ||
812 | |||
813 | $user = static::$kernel->getContainer()->get('security.token_storage')->getToken()->getUser(); | ||
814 | |||
815 | $tag = new Tag(); | ||
816 | $tag->setLabel('super'); | ||
817 | $em->persist($tag); | ||
818 | |||
819 | $entry = new Entry($user); | ||
820 | $entry->setUrl('http://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html'); | ||
821 | $entry->setContent('Youhou'); | ||
822 | $entry->setTitle('Youhou'); | ||
823 | $entry->addTag($tag); | ||
824 | $em->persist($entry); | ||
825 | |||
826 | $annotation = new Annotation($user); | ||
827 | $annotation->setText('annotated'); | ||
828 | $annotation->setQuote('annotated'); | ||
829 | $annotation->setRanges([]); | ||
830 | $annotation->setEntry($entry); | ||
831 | $em->persist($annotation); | ||
832 | |||
833 | $tagArchived = new Tag(); | ||
834 | $tagArchived->setLabel('super'); | ||
835 | $em->persist($tagArchived); | ||
836 | |||
837 | $entryArchived = new Entry($user); | ||
838 | $entryArchived->setUrl('http://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html'); | ||
839 | $entryArchived->setContent('Youhou'); | ||
840 | $entryArchived->setTitle('Youhou'); | ||
841 | $entryArchived->addTag($tagArchived); | ||
842 | $entryArchived->setArchived(true); | ||
843 | $em->persist($entryArchived); | ||
844 | |||
845 | $annotationArchived = new Annotation($user); | ||
846 | $annotationArchived->setText('annotated'); | ||
847 | $annotationArchived->setQuote('annotated'); | ||
848 | $annotationArchived->setRanges([]); | ||
849 | $annotationArchived->setEntry($entryArchived); | ||
850 | $em->persist($annotationArchived); | ||
851 | |||
852 | $em->flush(); | ||
853 | |||
854 | $crawler = $client->request('GET', '/config#set3'); | ||
855 | |||
856 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
857 | |||
858 | $crawler = $client->click($crawler->selectLink('config.reset.archived')->link()); | ||
859 | |||
860 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
861 | $this->assertContains('flashes.config.notice.archived_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]); | ||
862 | |||
863 | $entryReset = $em | ||
864 | ->getRepository('WallabagCoreBundle:Entry') | ||
865 | ->countAllEntriesByUser($user->getId()); | ||
866 | |||
867 | $this->assertEquals(1, $entryReset, 'Entries were reset'); | ||
868 | |||
869 | $tagReset = $em | ||
870 | ->getRepository('WallabagCoreBundle:Tag') | ||
871 | ->countAllTags($user->getId()); | ||
872 | |||
873 | $this->assertEquals(1, $tagReset, 'Tags were reset'); | ||
874 | |||
875 | $annotationsReset = $em | ||
876 | ->getRepository('WallabagAnnotationBundle:Annotation') | ||
877 | ->findAnnotationsByPageId($annotationArchived->getId(), $user->getId()); | ||
878 | |||
879 | $this->assertEmpty($annotationsReset, 'Annotations were reset'); | ||
880 | } | ||
881 | |||
806 | public function testResetEntriesCascade() | 882 | public function testResetEntriesCascade() |
807 | { | 883 | { |
808 | $this->logInAs('empty'); | 884 | $this->logInAs('empty'); |
@@ -843,7 +919,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
843 | 919 | ||
844 | $entryReset = $em | 920 | $entryReset = $em |
845 | ->getRepository('WallabagCoreBundle:Entry') | 921 | ->getRepository('WallabagCoreBundle:Entry') |
846 | ->countAllEntriesByUsername($user->getId()); | 922 | ->countAllEntriesByUser($user->getId()); |
847 | 923 | ||
848 | $this->assertEquals(0, $entryReset, 'Entries were reset'); | 924 | $this->assertEquals(0, $entryReset, 'Entries were reset'); |
849 | 925 | ||
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 7db4cf1f..116e5f32 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -8,8 +8,24 @@ use Wallabag\CoreBundle\Entity\Entry; | |||
8 | 8 | ||
9 | class EntryControllerTest extends WallabagCoreTestCase | 9 | class EntryControllerTest extends WallabagCoreTestCase |
10 | { | 10 | { |
11 | public $downloadImagesEnabled = false; | ||
11 | public $url = 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html'; | 12 | public $url = 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html'; |
12 | 13 | ||
14 | /** | ||
15 | * @after | ||
16 | * | ||
17 | * Ensure download_images_enabled is disabled after each script | ||
18 | */ | ||
19 | public function tearDownImagesEnabled() | ||
20 | { | ||
21 | if ($this->downloadImagesEnabled) { | ||
22 | $client = static::createClient(); | ||
23 | $client->getContainer()->get('craue_config')->set('download_images_enabled', 0); | ||
24 | |||
25 | $this->downloadImagesEnabled = false; | ||
26 | } | ||
27 | } | ||
28 | |||
13 | public function testLogin() | 29 | public function testLogin() |
14 | { | 30 | { |
15 | $client = $this->getClient(); | 31 | $client = $this->getClient(); |
@@ -135,9 +151,45 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
135 | ->getRepository('WallabagCoreBundle:Entry') | 151 | ->getRepository('WallabagCoreBundle:Entry') |
136 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | 152 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
137 | 153 | ||
154 | $author = $content->getPublishedBy(); | ||
155 | |||
138 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); | 156 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); |
139 | $this->assertEquals($this->url, $content->getUrl()); | 157 | $this->assertEquals($this->url, $content->getUrl()); |
140 | $this->assertContains('Google', $content->getTitle()); | 158 | $this->assertContains('Google', $content->getTitle()); |
159 | $this->assertEquals('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s')); | ||
160 | $this->assertEquals('Morgane Tual', $author[0]); | ||
161 | $this->assertArrayHasKey('x-varnish1', $content->getHeaders()); | ||
162 | } | ||
163 | |||
164 | public function testPostWithMultipleAuthors() | ||
165 | { | ||
166 | $url = 'http://www.liberation.fr/planete/2017/04/05/donald-trump-et-xi-jinping-tentative-de-flirt-en-floride_1560768'; | ||
167 | $this->logInAs('admin'); | ||
168 | $client = $this->getClient(); | ||
169 | |||
170 | $crawler = $client->request('GET', '/new'); | ||
171 | |||
172 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
173 | |||
174 | $form = $crawler->filter('form[name=entry]')->form(); | ||
175 | |||
176 | $data = [ | ||
177 | 'entry[url]' => $url, | ||
178 | ]; | ||
179 | |||
180 | $client->submit($form, $data); | ||
181 | |||
182 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
183 | |||
184 | $content = $client->getContainer() | ||
185 | ->get('doctrine.orm.entity_manager') | ||
186 | ->getRepository('WallabagCoreBundle:Entry') | ||
187 | ->findByUrlAndUserId($url, $this->getLoggedInUserId()); | ||
188 | |||
189 | $authors = $content->getPublishedBy(); | ||
190 | $this->assertEquals('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s')); | ||
191 | $this->assertEquals('Raphaël Balenieri, correspondant à Pékin', $authors[0]); | ||
192 | $this->assertEquals('Frédéric Autran, correspondant à New York', $authors[1]); | ||
141 | } | 193 | } |
142 | 194 | ||
143 | public function testPostNewOkUrlExist() | 195 | public function testPostNewOkUrlExist() |
@@ -235,7 +287,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
235 | ->findOneByUrl($url); | 287 | ->findOneByUrl($url); |
236 | $tags = $entry->getTags(); | 288 | $tags = $entry->getTags(); |
237 | 289 | ||
238 | $this->assertCount(1, $tags); | 290 | $this->assertCount(2, $tags); |
239 | $this->assertEquals('wallabag', $tags[0]->getLabel()); | 291 | $this->assertEquals('wallabag', $tags[0]->getLabel()); |
240 | 292 | ||
241 | $em->remove($entry); | 293 | $em->remove($entry); |
@@ -264,8 +316,8 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
264 | 316 | ||
265 | $tags = $entry->getTags(); | 317 | $tags = $entry->getTags(); |
266 | 318 | ||
267 | $this->assertCount(1, $tags); | 319 | $this->assertCount(2, $tags); |
268 | $this->assertEquals('wallabag', $tags[0]->getLabel()); | 320 | $this->assertEquals('wallabag', $tags[1]->getLabel()); |
269 | 321 | ||
270 | $em->remove($entry); | 322 | $em->remove($entry); |
271 | $em->flush(); | 323 | $em->flush(); |
@@ -626,7 +678,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
626 | 678 | ||
627 | $crawler = $client->submit($form, $data); | 679 | $crawler = $client->submit($form, $data); |
628 | 680 | ||
629 | $this->assertCount(2, $crawler->filter('div[class=entry]')); | 681 | $this->assertCount(3, $crawler->filter('div[class=entry]')); |
630 | } | 682 | } |
631 | 683 | ||
632 | public function testFilterOnReadingTimeOnlyLower() | 684 | public function testFilterOnReadingTimeOnlyLower() |
@@ -662,7 +714,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
662 | 714 | ||
663 | $crawler = $client->submit($form, $data); | 715 | $crawler = $client->submit($form, $data); |
664 | 716 | ||
665 | $this->assertCount(4, $crawler->filter('div[class=entry]')); | 717 | $this->assertCount(5, $crawler->filter('div[class=entry]')); |
666 | } | 718 | } |
667 | 719 | ||
668 | public function testFilterOnCreationDate() | 720 | public function testFilterOnCreationDate() |
@@ -681,7 +733,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
681 | 733 | ||
682 | $crawler = $client->submit($form, $data); | 734 | $crawler = $client->submit($form, $data); |
683 | 735 | ||
684 | $this->assertCount(5, $crawler->filter('div[class=entry]')); | 736 | $this->assertCount(6, $crawler->filter('div[class=entry]')); |
685 | 737 | ||
686 | $data = [ | 738 | $data = [ |
687 | 'entry_filter[createdAt][left_date]' => date('d/m/Y'), | 739 | 'entry_filter[createdAt][left_date]' => date('d/m/Y'), |
@@ -690,7 +742,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
690 | 742 | ||
691 | $crawler = $client->submit($form, $data); | 743 | $crawler = $client->submit($form, $data); |
692 | 744 | ||
693 | $this->assertCount(5, $crawler->filter('div[class=entry]')); | 745 | $this->assertCount(6, $crawler->filter('div[class=entry]')); |
694 | 746 | ||
695 | $data = [ | 747 | $data = [ |
696 | 'entry_filter[createdAt][left_date]' => '01/01/1970', | 748 | 'entry_filter[createdAt][left_date]' => '01/01/1970', |
@@ -794,7 +846,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
794 | $form['entry_filter[previewPicture]']->tick(); | 846 | $form['entry_filter[previewPicture]']->tick(); |
795 | 847 | ||
796 | $crawler = $client->submit($form); | 848 | $crawler = $client->submit($form); |
797 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | 849 | $this->assertCount(2, $crawler->filter('div[class=entry]')); |
798 | } | 850 | } |
799 | 851 | ||
800 | public function testFilterOnLanguage() | 852 | public function testFilterOnLanguage() |
@@ -809,7 +861,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
809 | ]; | 861 | ]; |
810 | 862 | ||
811 | $crawler = $client->submit($form, $data); | 863 | $crawler = $client->submit($form, $data); |
812 | $this->assertCount(2, $crawler->filter('div[class=entry]')); | 864 | $this->assertCount(3, $crawler->filter('div[class=entry]')); |
813 | 865 | ||
814 | $form = $crawler->filter('button[id=submit-filter]')->form(); | 866 | $form = $crawler->filter('button[id=submit-filter]')->form(); |
815 | $data = [ | 867 | $data = [ |
@@ -869,6 +921,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
869 | 921 | ||
870 | public function testNewEntryWithDownloadImagesEnabled() | 922 | public function testNewEntryWithDownloadImagesEnabled() |
871 | { | 923 | { |
924 | $this->downloadImagesEnabled = true; | ||
872 | $this->logInAs('admin'); | 925 | $this->logInAs('admin'); |
873 | $client = $this->getClient(); | 926 | $client = $this->getClient(); |
874 | 927 | ||
@@ -899,7 +952,8 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
899 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry); | 952 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry); |
900 | $this->assertEquals($url, $entry->getUrl()); | 953 | $this->assertEquals($url, $entry->getUrl()); |
901 | $this->assertContains('Perpignan', $entry->getTitle()); | 954 | $this->assertContains('Perpignan', $entry->getTitle()); |
902 | $this->assertContains('/d9bc0fcd.jpeg', $entry->getContent()); | 955 | // instead of checking for the filename (which might change) check that the image is now local |
956 | $this->assertContains('http://v2.wallabag.org/assets/images/', $entry->getContent()); | ||
903 | 957 | ||
904 | $client->getContainer()->get('craue_config')->set('download_images_enabled', 0); | 958 | $client->getContainer()->get('craue_config')->set('download_images_enabled', 0); |
905 | } | 959 | } |
@@ -909,6 +963,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
909 | */ | 963 | */ |
910 | public function testRemoveEntryWithDownloadImagesEnabled() | 964 | public function testRemoveEntryWithDownloadImagesEnabled() |
911 | { | 965 | { |
966 | $this->downloadImagesEnabled = true; | ||
912 | $this->logInAs('admin'); | 967 | $this->logInAs('admin'); |
913 | $client = $this->getClient(); | 968 | $client = $this->getClient(); |
914 | 969 | ||
@@ -1034,7 +1089,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1034 | 1089 | ||
1035 | $crawler = $client->submit($form, $data); | 1090 | $crawler = $client->submit($form, $data); |
1036 | 1091 | ||
1037 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | 1092 | $this->assertCount(2, $crawler->filter('div[class=entry]')); |
1038 | 1093 | ||
1039 | $crawler = $client->request('GET', '/all/list'); | 1094 | $crawler = $client->request('GET', '/all/list'); |
1040 | $form = $crawler->filter('button[id=submit-filter]')->form(); | 1095 | $form = $crawler->filter('button[id=submit-filter]')->form(); |
@@ -1045,7 +1100,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1045 | 1100 | ||
1046 | $crawler = $client->submit($form, $data); | 1101 | $crawler = $client->submit($form, $data); |
1047 | 1102 | ||
1048 | $this->assertCount(7, $crawler->filter('div[class=entry]')); | 1103 | $this->assertCount(8, $crawler->filter('div[class=entry]')); |
1049 | } | 1104 | } |
1050 | 1105 | ||
1051 | public function testSearch() | 1106 | public function testSearch() |
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php index 32a18e26..63f2c829 100644 --- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | |||
@@ -189,11 +189,9 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
189 | $this->assertContains($contentInDB[0]['language'], $csv[1]); | 189 | $this->assertContains($contentInDB[0]['language'], $csv[1]); |
190 | $this->assertContains($contentInDB[0]['createdAt']->format('d/m/Y h:i:s'), $csv[1]); | 190 | $this->assertContains($contentInDB[0]['createdAt']->format('d/m/Y h:i:s'), $csv[1]); |
191 | 191 | ||
192 | $expectedTag = []; | ||
193 | foreach ($contentInDB[0]['tags'] as $tag) { | 192 | foreach ($contentInDB[0]['tags'] as $tag) { |
194 | $expectedTag[] = $tag['label']; | 193 | $this->assertContains($tag['label'], $csv[1]); |
195 | } | 194 | } |
196 | $this->assertContains(implode(', ', $expectedTag), $csv[1]); | ||
197 | } | 195 | } |
198 | 196 | ||
199 | public function testJsonExport() | 197 | public function testJsonExport() |
@@ -241,7 +239,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
241 | $this->assertEquals($contentInDB->getLanguage(), $content[0]['language']); | 239 | $this->assertEquals($contentInDB->getLanguage(), $content[0]['language']); |
242 | $this->assertEquals($contentInDB->getReadingtime(), $content[0]['reading_time']); | 240 | $this->assertEquals($contentInDB->getReadingtime(), $content[0]['reading_time']); |
243 | $this->assertEquals($contentInDB->getDomainname(), $content[0]['domain_name']); | 241 | $this->assertEquals($contentInDB->getDomainname(), $content[0]['domain_name']); |
244 | $this->assertEquals(['foo bar', 'baz'], $content[0]['tags']); | 242 | $this->assertEquals(['foo bar', 'baz', 'foot'], $content[0]['tags']); |
245 | } | 243 | } |
246 | 244 | ||
247 | public function testXmlExport() | 245 | public function testXmlExport() |
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php index fa1a3539..c3b22dcd 100644 --- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php | |||
@@ -46,7 +46,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
46 | ->getRepository('WallabagCoreBundle:Entry') | 46 | ->getRepository('WallabagCoreBundle:Entry') |
47 | ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId()); | 47 | ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId()); |
48 | 48 | ||
49 | $this->assertEquals(3, count($entry->getTags())); | 49 | $this->assertEquals(4, count($entry->getTags())); |
50 | 50 | ||
51 | // tag already exists and already assigned | 51 | // tag already exists and already assigned |
52 | $client->submit($form, $data); | 52 | $client->submit($form, $data); |
@@ -57,7 +57,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
57 | ->getRepository('WallabagCoreBundle:Entry') | 57 | ->getRepository('WallabagCoreBundle:Entry') |
58 | ->find($entry->getId()); | 58 | ->find($entry->getId()); |
59 | 59 | ||
60 | $this->assertEquals(3, count($newEntry->getTags())); | 60 | $this->assertEquals(4, count($newEntry->getTags())); |
61 | 61 | ||
62 | // tag already exists but still not assigned to this entry | 62 | // tag already exists but still not assigned to this entry |
63 | $data = [ | 63 | $data = [ |
@@ -72,7 +72,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
72 | ->getRepository('WallabagCoreBundle:Entry') | 72 | ->getRepository('WallabagCoreBundle:Entry') |
73 | ->find($entry->getId()); | 73 | ->find($entry->getId()); |
74 | 74 | ||
75 | $this->assertEquals(3, count($newEntry->getTags())); | 75 | $this->assertEquals(4, count($newEntry->getTags())); |
76 | } | 76 | } |
77 | 77 | ||
78 | public function testAddMultipleTagToEntry() | 78 | public function testAddMultipleTagToEntry() |
diff --git a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php index aee67259..8b50bce9 100644 --- a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php +++ b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator; | 3 | namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator; |
4 | 4 | ||
5 | use Monolog\Handler\TestHandler; | ||
6 | use Monolog\Logger; | ||
5 | use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig; | 7 | use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig; |
6 | use Graby\SiteConfig\SiteConfig as GrabySiteConfig; | 8 | use Graby\SiteConfig\SiteConfig as GrabySiteConfig; |
7 | use PHPUnit_Framework_TestCase; | 9 | use PHPUnit_Framework_TestCase; |
@@ -24,7 +26,7 @@ class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase | |||
24 | $grabySiteConfig->login_uri = 'http://example.com/login'; | 26 | $grabySiteConfig->login_uri = 'http://example.com/login'; |
25 | $grabySiteConfig->login_username_field = 'login'; | 27 | $grabySiteConfig->login_username_field = 'login'; |
26 | $grabySiteConfig->login_password_field = 'password'; | 28 | $grabySiteConfig->login_password_field = 'password'; |
27 | $grabySiteConfig->login_extra_fields = ['field' => 'value']; | 29 | $grabySiteConfig->login_extra_fields = ['field=value']; |
28 | $grabySiteConfig->not_logged_in_xpath = '//div[@class="need-login"]'; | 30 | $grabySiteConfig->not_logged_in_xpath = '//div[@class="need-login"]'; |
29 | 31 | ||
30 | $grabyConfigBuilderMock | 32 | $grabyConfigBuilderMock |
@@ -32,14 +34,19 @@ class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase | |||
32 | ->with('example.com') | 34 | ->with('example.com') |
33 | ->will($this->returnValue($grabySiteConfig)); | 35 | ->will($this->returnValue($grabySiteConfig)); |
34 | 36 | ||
37 | $logger = new Logger('foo'); | ||
38 | $handler = new TestHandler(); | ||
39 | $logger->pushHandler($handler); | ||
40 | |||
35 | $this->builder = new GrabySiteConfigBuilder( | 41 | $this->builder = new GrabySiteConfigBuilder( |
36 | $grabyConfigBuilderMock, | 42 | $grabyConfigBuilderMock, |
37 | ['example.com' => ['username' => 'foo', 'password' => 'bar']] | 43 | ['example.com' => ['username' => 'foo', 'password' => 'bar']], |
44 | $logger | ||
38 | ); | 45 | ); |
39 | 46 | ||
40 | $config = $this->builder->buildForHost('example.com'); | 47 | $config = $this->builder->buildForHost('example.com'); |
41 | 48 | ||
42 | self::assertEquals( | 49 | $this->assertEquals( |
43 | new SiteConfig([ | 50 | new SiteConfig([ |
44 | 'host' => 'example.com', | 51 | 'host' => 'example.com', |
45 | 'requiresLogin' => true, | 52 | 'requiresLogin' => true, |
@@ -53,6 +60,10 @@ class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase | |||
53 | ]), | 60 | ]), |
54 | $config | 61 | $config |
55 | ); | 62 | ); |
63 | |||
64 | $records = $handler->getRecords(); | ||
65 | |||
66 | $this->assertCount(1, $records, 'One log was recorded'); | ||
56 | } | 67 | } |
57 | 68 | ||
58 | public function testBuildConfigDoesntExist() | 69 | public function testBuildConfigDoesntExist() |
@@ -67,19 +78,22 @@ class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase | |||
67 | ->with('unknown.com') | 78 | ->with('unknown.com') |
68 | ->will($this->returnValue(new GrabySiteConfig())); | 79 | ->will($this->returnValue(new GrabySiteConfig())); |
69 | 80 | ||
70 | $this->builder = new GrabySiteConfigBuilder($grabyConfigBuilderMock, []); | 81 | $logger = new Logger('foo'); |
82 | $handler = new TestHandler(); | ||
83 | $logger->pushHandler($handler); | ||
84 | |||
85 | $this->builder = new GrabySiteConfigBuilder( | ||
86 | $grabyConfigBuilderMock, | ||
87 | [], | ||
88 | $logger | ||
89 | ); | ||
71 | 90 | ||
72 | $config = $this->builder->buildForHost('unknown.com'); | 91 | $config = $this->builder->buildForHost('unknown.com'); |
73 | 92 | ||
74 | self::assertEquals( | 93 | $this->assertFalse($config); |
75 | new SiteConfig([ | 94 | |
76 | 'host' => 'unknown.com', | 95 | $records = $handler->getRecords(); |
77 | 'requiresLogin' => false, | 96 | |
78 | 'username' => null, | 97 | $this->assertCount(1, $records, 'One log was recorded'); |
79 | 'password' => null, | ||
80 | 'extraFields' => [], | ||
81 | ]), | ||
82 | $config | ||
83 | ); | ||
84 | } | 98 | } |
85 | } | 99 | } |
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php index 4f70ed0c..77dfd5bf 100644 --- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | |||
@@ -7,6 +7,8 @@ use Wallabag\CoreBundle\Helper\ContentProxy; | |||
7 | use Wallabag\CoreBundle\Entity\Entry; | 7 | use Wallabag\CoreBundle\Entity\Entry; |
8 | use Wallabag\CoreBundle\Entity\Tag; | 8 | use Wallabag\CoreBundle\Entity\Tag; |
9 | use Wallabag\UserBundle\Entity\User; | 9 | use Wallabag\UserBundle\Entity\User; |
10 | use Wallabag\CoreBundle\Repository\TagRepository; | ||
11 | use Wallabag\CoreBundle\Helper\RuleBasedTagger; | ||
10 | 12 | ||
11 | class ContentProxyTest extends \PHPUnit_Framework_TestCase | 13 | class ContentProxyTest extends \PHPUnit_Framework_TestCase |
12 | { | 14 | { |
@@ -33,7 +35,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
33 | 'language' => '', | 35 | 'language' => '', |
34 | ]); | 36 | ]); |
35 | 37 | ||
36 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); | 38 | $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); |
37 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80'); | 39 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80'); |
38 | 40 | ||
39 | $this->assertEquals('http://user@:80', $entry->getUrl()); | 41 | $this->assertEquals('http://user@:80', $entry->getUrl()); |
@@ -67,7 +69,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
67 | 'language' => '', | 69 | 'language' => '', |
68 | ]); | 70 | ]); |
69 | 71 | ||
70 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); | 72 | $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); |
71 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); | 73 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); |
72 | 74 | ||
73 | $this->assertEquals('http://0.0.0.0', $entry->getUrl()); | 75 | $this->assertEquals('http://0.0.0.0', $entry->getUrl()); |
@@ -106,12 +108,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
106 | ], | 108 | ], |
107 | ]); | 109 | ]); |
108 | 110 | ||
109 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); | 111 | $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); |
110 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io'); | 112 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io'); |
111 | 113 | ||
112 | $this->assertEquals('http://domain.io', $entry->getUrl()); | 114 | $this->assertEquals('http://domain.io', $entry->getUrl()); |
113 | $this->assertEquals('my title', $entry->getTitle()); | 115 | $this->assertEquals('my title', $entry->getTitle()); |
114 | $this->assertEquals($this->fetchingErrorMessage . '<p><i>But we found a short description: </i></p>desc', $entry->getContent()); | 116 | $this->assertEquals($this->fetchingErrorMessage.'<p><i>But we found a short description: </i></p>desc', $entry->getContent()); |
115 | $this->assertEmpty($entry->getPreviewPicture()); | 117 | $this->assertEmpty($entry->getPreviewPicture()); |
116 | $this->assertEmpty($entry->getLanguage()); | 118 | $this->assertEmpty($entry->getLanguage()); |
117 | $this->assertEmpty($entry->getHttpStatus()); | 119 | $this->assertEmpty($entry->getHttpStatus()); |
@@ -147,7 +149,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
147 | ], | 149 | ], |
148 | ]); | 150 | ]); |
149 | 151 | ||
150 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); | 152 | $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); |
151 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); | 153 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); |
152 | 154 | ||
153 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); | 155 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); |
@@ -188,7 +190,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
188 | ], | 190 | ], |
189 | ]); | 191 | ]); |
190 | 192 | ||
191 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); | 193 | $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); |
192 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); | 194 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); |
193 | 195 | ||
194 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); | 196 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); |
@@ -210,7 +212,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
210 | 212 | ||
211 | $graby = $this->getMockBuilder('Graby\Graby')->getMock(); | 213 | $graby = $this->getMockBuilder('Graby\Graby')->getMock(); |
212 | 214 | ||
213 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); | 215 | $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); |
214 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ | 216 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ |
215 | 'html' => str_repeat('this is my content', 325), | 217 | 'html' => str_repeat('this is my content', 325), |
216 | 'title' => 'this is my title', | 218 | 'title' => 'this is my title', |
@@ -239,8 +241,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
239 | ->method('tag') | 241 | ->method('tag') |
240 | ->will($this->throwException(new \Exception())); | 242 | ->will($this->throwException(new \Exception())); |
241 | 243 | ||
242 | $tagRepo = $this->getTagRepositoryMock(); | 244 | $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); |
243 | $proxy = new ContentProxy($graby, $tagger, $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); | ||
244 | 245 | ||
245 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ | 246 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ |
246 | 'html' => str_repeat('this is my content', 325), | 247 | 'html' => str_repeat('this is my content', 325), |
@@ -253,134 +254,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
253 | $this->assertCount(0, $entry->getTags()); | 254 | $this->assertCount(0, $entry->getTags()); |
254 | } | 255 | } |
255 | 256 | ||
256 | public function testAssignTagsWithArrayAndExtraSpaces() | ||
257 | { | ||
258 | $graby = $this->getMockBuilder('Graby\Graby') | ||
259 | ->disableOriginalConstructor() | ||
260 | ->getMock(); | ||
261 | |||
262 | $tagRepo = $this->getTagRepositoryMock(); | ||
263 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); | ||
264 | |||
265 | $entry = new Entry(new User()); | ||
266 | |||
267 | $proxy->assignTagsToEntry($entry, [' tag1', 'tag2 ']); | ||
268 | |||
269 | $this->assertCount(2, $entry->getTags()); | ||
270 | $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); | ||
271 | $this->assertEquals('tag2', $entry->getTags()[1]->getLabel()); | ||
272 | } | ||
273 | |||
274 | public function testAssignTagsWithString() | ||
275 | { | ||
276 | $graby = $this->getMockBuilder('Graby\Graby') | ||
277 | ->disableOriginalConstructor() | ||
278 | ->getMock(); | ||
279 | |||
280 | $tagRepo = $this->getTagRepositoryMock(); | ||
281 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); | ||
282 | |||
283 | $entry = new Entry(new User()); | ||
284 | |||
285 | $proxy->assignTagsToEntry($entry, 'tag1, tag2'); | ||
286 | |||
287 | $this->assertCount(2, $entry->getTags()); | ||
288 | $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); | ||
289 | $this->assertEquals('tag2', $entry->getTags()[1]->getLabel()); | ||
290 | } | ||
291 | |||
292 | public function testAssignTagsWithEmptyArray() | ||
293 | { | ||
294 | $graby = $this->getMockBuilder('Graby\Graby') | ||
295 | ->disableOriginalConstructor() | ||
296 | ->getMock(); | ||
297 | |||
298 | $tagRepo = $this->getTagRepositoryMock(); | ||
299 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); | ||
300 | |||
301 | $entry = new Entry(new User()); | ||
302 | |||
303 | $proxy->assignTagsToEntry($entry, []); | ||
304 | |||
305 | $this->assertCount(0, $entry->getTags()); | ||
306 | } | ||
307 | |||
308 | public function testAssignTagsWithEmptyString() | ||
309 | { | ||
310 | $graby = $this->getMockBuilder('Graby\Graby') | ||
311 | ->disableOriginalConstructor() | ||
312 | ->getMock(); | ||
313 | |||
314 | $tagRepo = $this->getTagRepositoryMock(); | ||
315 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); | ||
316 | |||
317 | $entry = new Entry(new User()); | ||
318 | |||
319 | $proxy->assignTagsToEntry($entry, ''); | ||
320 | |||
321 | $this->assertCount(0, $entry->getTags()); | ||
322 | } | ||
323 | |||
324 | public function testAssignTagsAlreadyAssigned() | ||
325 | { | ||
326 | $graby = $this->getMockBuilder('Graby\Graby') | ||
327 | ->disableOriginalConstructor() | ||
328 | ->getMock(); | ||
329 | |||
330 | $tagRepo = $this->getTagRepositoryMock(); | ||
331 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); | ||
332 | |||
333 | $tagEntity = new Tag(); | ||
334 | $tagEntity->setLabel('tag1'); | ||
335 | |||
336 | $entry = new Entry(new User()); | ||
337 | $entry->addTag($tagEntity); | ||
338 | |||
339 | $proxy->assignTagsToEntry($entry, 'tag1, tag2'); | ||
340 | |||
341 | $this->assertCount(2, $entry->getTags()); | ||
342 | $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); | ||
343 | $this->assertEquals('tag2', $entry->getTags()[1]->getLabel()); | ||
344 | } | ||
345 | |||
346 | public function testAssignTagsNotFlushed() | ||
347 | { | ||
348 | $graby = $this->getMockBuilder('Graby\Graby') | ||
349 | ->disableOriginalConstructor() | ||
350 | ->getMock(); | ||
351 | |||
352 | $tagRepo = $this->getTagRepositoryMock(); | ||
353 | $tagRepo->expects($this->never()) | ||
354 | ->method('__call'); | ||
355 | |||
356 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); | ||
357 | |||
358 | $tagEntity = new Tag(); | ||
359 | $tagEntity->setLabel('tag1'); | ||
360 | |||
361 | $entry = new Entry(new User()); | ||
362 | |||
363 | $proxy->assignTagsToEntry($entry, 'tag1', [$tagEntity]); | ||
364 | |||
365 | $this->assertCount(1, $entry->getTags()); | ||
366 | $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); | ||
367 | } | ||
368 | |||
369 | private function getTaggerMock() | 257 | private function getTaggerMock() |
370 | { | 258 | { |
371 | return $this->getMockBuilder('Wallabag\CoreBundle\Helper\RuleBasedTagger') | 259 | return $this->getMockBuilder(RuleBasedTagger::class) |
372 | ->setMethods(['tag']) | 260 | ->setMethods(['tag']) |
373 | ->disableOriginalConstructor() | 261 | ->disableOriginalConstructor() |
374 | ->getMock(); | 262 | ->getMock(); |
375 | } | 263 | } |
376 | 264 | ||
377 | private function getTagRepositoryMock() | ||
378 | { | ||
379 | return $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository') | ||
380 | ->disableOriginalConstructor() | ||
381 | ->getMock(); | ||
382 | } | ||
383 | |||
384 | private function getLogger() | 265 | private function getLogger() |
385 | { | 266 | { |
386 | return new NullLogger(); | 267 | return new NullLogger(); |
diff --git a/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php b/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php index 17b08c2a..1e21f400 100644 --- a/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php +++ b/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | namespace Tests\Wallabag\CoreBundle\Helper; | 3 | namespace Tests\Wallabag\CoreBundle\Helper; |
4 | 4 | ||
5 | use Monolog\Handler\TestHandler; | ||
6 | use Monolog\Logger; | ||
5 | use Wallabag\CoreBundle\Entity\Config; | 7 | use Wallabag\CoreBundle\Entity\Config; |
6 | use Wallabag\CoreBundle\Entity\Entry; | 8 | use Wallabag\CoreBundle\Entity\Entry; |
7 | use Wallabag\CoreBundle\Entity\Tag; | 9 | use Wallabag\CoreBundle\Entity\Tag; |
@@ -15,14 +17,19 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase | |||
15 | private $tagRepository; | 17 | private $tagRepository; |
16 | private $entryRepository; | 18 | private $entryRepository; |
17 | private $tagger; | 19 | private $tagger; |
20 | private $logger; | ||
21 | private $handler; | ||
18 | 22 | ||
19 | public function setUp() | 23 | public function setUp() |
20 | { | 24 | { |
21 | $this->rulerz = $this->getRulerZMock(); | 25 | $this->rulerz = $this->getRulerZMock(); |
22 | $this->tagRepository = $this->getTagRepositoryMock(); | 26 | $this->tagRepository = $this->getTagRepositoryMock(); |
23 | $this->entryRepository = $this->getEntryRepositoryMock(); | 27 | $this->entryRepository = $this->getEntryRepositoryMock(); |
28 | $this->logger = $this->getLogger(); | ||
29 | $this->handler = new TestHandler(); | ||
30 | $this->logger->pushHandler($this->handler); | ||
24 | 31 | ||
25 | $this->tagger = new RuleBasedTagger($this->rulerz, $this->tagRepository, $this->entryRepository); | 32 | $this->tagger = new RuleBasedTagger($this->rulerz, $this->tagRepository, $this->entryRepository, $this->logger); |
26 | } | 33 | } |
27 | 34 | ||
28 | public function testTagWithNoRule() | 35 | public function testTagWithNoRule() |
@@ -32,6 +39,8 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase | |||
32 | $this->tagger->tag($entry); | 39 | $this->tagger->tag($entry); |
33 | 40 | ||
34 | $this->assertTrue($entry->getTags()->isEmpty()); | 41 | $this->assertTrue($entry->getTags()->isEmpty()); |
42 | $records = $this->handler->getRecords(); | ||
43 | $this->assertCount(0, $records); | ||
35 | } | 44 | } |
36 | 45 | ||
37 | public function testTagWithNoMatchingRule() | 46 | public function testTagWithNoMatchingRule() |
@@ -49,6 +58,8 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase | |||
49 | $this->tagger->tag($entry); | 58 | $this->tagger->tag($entry); |
50 | 59 | ||
51 | $this->assertTrue($entry->getTags()->isEmpty()); | 60 | $this->assertTrue($entry->getTags()->isEmpty()); |
61 | $records = $this->handler->getRecords(); | ||
62 | $this->assertCount(0, $records); | ||
52 | } | 63 | } |
53 | 64 | ||
54 | public function testTagWithAMatchingRule() | 65 | public function testTagWithAMatchingRule() |
@@ -70,6 +81,9 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase | |||
70 | $tags = $entry->getTags(); | 81 | $tags = $entry->getTags(); |
71 | $this->assertSame('foo', $tags[0]->getLabel()); | 82 | $this->assertSame('foo', $tags[0]->getLabel()); |
72 | $this->assertSame('bar', $tags[1]->getLabel()); | 83 | $this->assertSame('bar', $tags[1]->getLabel()); |
84 | |||
85 | $records = $this->handler->getRecords(); | ||
86 | $this->assertCount(1, $records); | ||
73 | } | 87 | } |
74 | 88 | ||
75 | public function testTagWithAMixOfMatchingRules() | 89 | public function testTagWithAMixOfMatchingRules() |
@@ -90,6 +104,8 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase | |||
90 | 104 | ||
91 | $tags = $entry->getTags(); | 105 | $tags = $entry->getTags(); |
92 | $this->assertSame('foo', $tags[0]->getLabel()); | 106 | $this->assertSame('foo', $tags[0]->getLabel()); |
107 | $records = $this->handler->getRecords(); | ||
108 | $this->assertCount(1, $records); | ||
93 | } | 109 | } |
94 | 110 | ||
95 | public function testWhenTheTagExists() | 111 | public function testWhenTheTagExists() |
@@ -118,6 +134,8 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase | |||
118 | 134 | ||
119 | $tags = $entry->getTags(); | 135 | $tags = $entry->getTags(); |
120 | $this->assertSame($tag, $tags[0]); | 136 | $this->assertSame($tag, $tags[0]); |
137 | $records = $this->handler->getRecords(); | ||
138 | $this->assertCount(1, $records); | ||
121 | } | 139 | } |
122 | 140 | ||
123 | public function testSameTagWithDifferentfMatchingRules() | 141 | public function testSameTagWithDifferentfMatchingRules() |
@@ -138,6 +156,8 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase | |||
138 | 156 | ||
139 | $tags = $entry->getTags(); | 157 | $tags = $entry->getTags(); |
140 | $this->assertCount(1, $tags); | 158 | $this->assertCount(1, $tags); |
159 | $records = $this->handler->getRecords(); | ||
160 | $this->assertCount(2, $records); | ||
141 | } | 161 | } |
142 | 162 | ||
143 | public function testTagAllEntriesForAUser() | 163 | public function testTagAllEntriesForAUser() |
@@ -209,4 +229,9 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase | |||
209 | ->disableOriginalConstructor() | 229 | ->disableOriginalConstructor() |
210 | ->getMock(); | 230 | ->getMock(); |
211 | } | 231 | } |
232 | |||
233 | private function getLogger() | ||
234 | { | ||
235 | return new Logger('foo'); | ||
236 | } | ||
212 | } | 237 | } |
diff --git a/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php b/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php new file mode 100644 index 00000000..6d6d6484 --- /dev/null +++ b/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php | |||
@@ -0,0 +1,108 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\CoreBundle\Helper; | ||
4 | |||
5 | use Wallabag\CoreBundle\Entity\Entry; | ||
6 | use Wallabag\CoreBundle\Entity\Tag; | ||
7 | use Wallabag\CoreBundle\Helper\TagsAssigner; | ||
8 | use Wallabag\UserBundle\Entity\User; | ||
9 | use Wallabag\CoreBundle\Repository\TagRepository; | ||
10 | |||
11 | class TagsAssignerTest extends \PHPUnit_Framework_TestCase | ||
12 | { | ||
13 | public function testAssignTagsWithArrayAndExtraSpaces() | ||
14 | { | ||
15 | $tagRepo = $this->getTagRepositoryMock(); | ||
16 | $tagsAssigner = new TagsAssigner($tagRepo); | ||
17 | |||
18 | $entry = new Entry(new User()); | ||
19 | |||
20 | $tagsAssigner->assignTagsToEntry($entry, [' tag1', 'tag2 ']); | ||
21 | |||
22 | $this->assertCount(2, $entry->getTags()); | ||
23 | $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); | ||
24 | $this->assertEquals('tag2', $entry->getTags()[1]->getLabel()); | ||
25 | } | ||
26 | |||
27 | public function testAssignTagsWithString() | ||
28 | { | ||
29 | $tagRepo = $this->getTagRepositoryMock(); | ||
30 | $tagsAssigner = new TagsAssigner($tagRepo); | ||
31 | |||
32 | $entry = new Entry(new User()); | ||
33 | |||
34 | $tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2'); | ||
35 | |||
36 | $this->assertCount(2, $entry->getTags()); | ||
37 | $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); | ||
38 | $this->assertEquals('tag2', $entry->getTags()[1]->getLabel()); | ||
39 | } | ||
40 | |||
41 | public function testAssignTagsWithEmptyArray() | ||
42 | { | ||
43 | $tagRepo = $this->getTagRepositoryMock(); | ||
44 | $tagsAssigner = new TagsAssigner($tagRepo); | ||
45 | |||
46 | $entry = new Entry(new User()); | ||
47 | |||
48 | $tagsAssigner->assignTagsToEntry($entry, []); | ||
49 | |||
50 | $this->assertCount(0, $entry->getTags()); | ||
51 | } | ||
52 | |||
53 | public function testAssignTagsWithEmptyString() | ||
54 | { | ||
55 | $tagRepo = $this->getTagRepositoryMock(); | ||
56 | $tagsAssigner = new TagsAssigner($tagRepo); | ||
57 | |||
58 | $entry = new Entry(new User()); | ||
59 | |||
60 | $tagsAssigner->assignTagsToEntry($entry, ''); | ||
61 | |||
62 | $this->assertCount(0, $entry->getTags()); | ||
63 | } | ||
64 | |||
65 | public function testAssignTagsAlreadyAssigned() | ||
66 | { | ||
67 | $tagRepo = $this->getTagRepositoryMock(); | ||
68 | $tagsAssigner = new TagsAssigner($tagRepo); | ||
69 | |||
70 | $tagEntity = new Tag(); | ||
71 | $tagEntity->setLabel('tag1'); | ||
72 | |||
73 | $entry = new Entry(new User()); | ||
74 | $entry->addTag($tagEntity); | ||
75 | |||
76 | $tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2'); | ||
77 | |||
78 | $this->assertCount(2, $entry->getTags()); | ||
79 | $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); | ||
80 | $this->assertEquals('tag2', $entry->getTags()[1]->getLabel()); | ||
81 | } | ||
82 | |||
83 | public function testAssignTagsNotFlushed() | ||
84 | { | ||
85 | $tagRepo = $this->getTagRepositoryMock(); | ||
86 | $tagRepo->expects($this->never()) | ||
87 | ->method('__call'); | ||
88 | |||
89 | $tagsAssigner = new TagsAssigner($tagRepo); | ||
90 | |||
91 | $tagEntity = new Tag(); | ||
92 | $tagEntity->setLabel('tag1'); | ||
93 | |||
94 | $entry = new Entry(new User()); | ||
95 | |||
96 | $tagsAssigner->assignTagsToEntry($entry, 'tag1', [$tagEntity]); | ||
97 | |||
98 | $this->assertCount(1, $entry->getTags()); | ||
99 | $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); | ||
100 | } | ||
101 | |||
102 | private function getTagRepositoryMock() | ||
103 | { | ||
104 | return $this->getMockBuilder(TagRepository::class) | ||
105 | ->disableOriginalConstructor() | ||
106 | ->getMock(); | ||
107 | } | ||
108 | } | ||
diff --git a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php index 7be1eb18..7043c345 100644 --- a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php +++ b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php | |||
@@ -10,7 +10,7 @@ use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | |||
10 | class ImportCommandTest extends WallabagCoreTestCase | 10 | class ImportCommandTest extends WallabagCoreTestCase |
11 | { | 11 | { |
12 | /** | 12 | /** |
13 | * @expectedException Symfony\Component\Console\Exception\RuntimeException | 13 | * @expectedException \Symfony\Component\Console\Exception\RuntimeException |
14 | * @expectedExceptionMessage Not enough arguments | 14 | * @expectedExceptionMessage Not enough arguments |
15 | */ | 15 | */ |
16 | public function testRunImportCommandWithoutArguments() | 16 | public function testRunImportCommandWithoutArguments() |
@@ -27,7 +27,7 @@ class ImportCommandTest extends WallabagCoreTestCase | |||
27 | } | 27 | } |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * @expectedException Symfony\Component\Config\Definition\Exception\Exception | 30 | * @expectedException \Symfony\Component\Config\Definition\Exception\Exception |
31 | * @expectedExceptionMessage not found | 31 | * @expectedExceptionMessage not found |
32 | */ | 32 | */ |
33 | public function testRunImportCommandWithoutFilepath() | 33 | public function testRunImportCommandWithoutFilepath() |
@@ -40,16 +40,15 @@ class ImportCommandTest extends WallabagCoreTestCase | |||
40 | $tester = new CommandTester($command); | 40 | $tester = new CommandTester($command); |
41 | $tester->execute([ | 41 | $tester->execute([ |
42 | 'command' => $command->getName(), | 42 | 'command' => $command->getName(), |
43 | 'userId' => 1, | 43 | 'username' => 'admin', |
44 | 'filepath' => 1, | 44 | 'filepath' => 1, |
45 | ]); | 45 | ]); |
46 | } | 46 | } |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * @expectedException Symfony\Component\Config\Definition\Exception\Exception | 49 | * @expectedException \Doctrine\ORM\NoResultException |
50 | * @expectedExceptionMessage User with id | ||
51 | */ | 50 | */ |
52 | public function testRunImportCommandWithoutUserId() | 51 | public function testRunImportCommandWithWrongUsername() |
53 | { | 52 | { |
54 | $application = new Application($this->getClient()->getKernel()); | 53 | $application = new Application($this->getClient()->getKernel()); |
55 | $application->add(new ImportCommand()); | 54 | $application->add(new ImportCommand()); |
@@ -59,7 +58,7 @@ class ImportCommandTest extends WallabagCoreTestCase | |||
59 | $tester = new CommandTester($command); | 58 | $tester = new CommandTester($command); |
60 | $tester->execute([ | 59 | $tester->execute([ |
61 | 'command' => $command->getName(), | 60 | 'command' => $command->getName(), |
62 | 'userId' => 0, | 61 | 'username' => 'random', |
63 | 'filepath' => './', | 62 | 'filepath' => './', |
64 | ]); | 63 | ]); |
65 | } | 64 | } |
@@ -74,7 +73,7 @@ class ImportCommandTest extends WallabagCoreTestCase | |||
74 | $tester = new CommandTester($command); | 73 | $tester = new CommandTester($command); |
75 | $tester->execute([ | 74 | $tester->execute([ |
76 | 'command' => $command->getName(), | 75 | 'command' => $command->getName(), |
77 | 'userId' => 1, | 76 | 'username' => 'admin', |
78 | 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir').'/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', | 77 | 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir').'/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', |
79 | '--importer' => 'v2', | 78 | '--importer' => 'v2', |
80 | ]); | 79 | ]); |
@@ -82,4 +81,20 @@ class ImportCommandTest extends WallabagCoreTestCase | |||
82 | $this->assertContains('imported', $tester->getDisplay()); | 81 | $this->assertContains('imported', $tester->getDisplay()); |
83 | $this->assertContains('already saved', $tester->getDisplay()); | 82 | $this->assertContains('already saved', $tester->getDisplay()); |
84 | } | 83 | } |
84 | |||
85 | public function testRunImportCommandWithUserId() | ||
86 | { | ||
87 | $application = new Application($this->getClient()->getKernel()); | ||
88 | $application->add(new ImportCommand()); | ||
89 | |||
90 | $command = $application->find('wallabag:import'); | ||
91 | |||
92 | $tester = new CommandTester($command); | ||
93 | $tester->execute([ | ||
94 | 'command' => $command->getName(), | ||
95 | 'username' => 1, | ||
96 | 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir').'/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', | ||
97 | '--useUserId' => true, | ||
98 | ]); | ||
99 | } | ||
85 | } | 100 | } |
diff --git a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php index c1f82ea9..8e9f65e3 100644 --- a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php | |||
@@ -120,7 +120,7 @@ class ChromeControllerTest extends WallabagCoreTestCase | |||
120 | 120 | ||
121 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.usinenouvelle.com is ok'); | 121 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.usinenouvelle.com is ok'); |
122 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.usinenouvelle.com is ok'); | 122 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.usinenouvelle.com is ok'); |
123 | $this->assertEquals(0, count($content->getTags())); | 123 | $this->assertEquals(1, count($content->getTags())); |
124 | 124 | ||
125 | $createdAt = $content->getCreatedAt(); | 125 | $createdAt = $content->getCreatedAt(); |
126 | $this->assertEquals('2011', $createdAt->format('Y')); | 126 | $this->assertEquals('2011', $createdAt->format('Y')); |
diff --git a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php index 7557ea32..5354439c 100644 --- a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php | |||
@@ -121,19 +121,19 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok'); | 121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok'); |
122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok'); | 122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok'); |
123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok'); | 123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok'); |
124 | $this->assertEquals(2, count($content->getTags())); | 124 | $this->assertEquals(3, count($content->getTags())); |
125 | 125 | ||
126 | $content = $client->getContainer() | 126 | $content = $client->getContainer() |
127 | ->get('doctrine.orm.entity_manager') | 127 | ->get('doctrine.orm.entity_manager') |
128 | ->getRepository('WallabagCoreBundle:Entry') | 128 | ->getRepository('WallabagCoreBundle:Entry') |
129 | ->findByUrlAndUserId( | 129 | ->findByUrlAndUserId( |
130 | 'http://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java', | 130 | 'https://stackoverflow.com/questions/15017163/parser-for-exported-bookmarks-html-file-of-google-chrome-and-mozilla-in-java', |
131 | $this->getLoggedInUserId() | 131 | $this->getLoggedInUserId() |
132 | ); | 132 | ); |
133 | 133 | ||
134 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://stackoverflow.com is ok'); | 134 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://stackoverflow.com is ok'); |
135 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://stackoverflow.com is ok'); | 135 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://stackoverflow.com is ok'); |
136 | $this->assertEmpty($content->getLanguage(), 'Language for http://stackoverflow.com is ok'); | 136 | $this->assertEmpty($content->getLanguage(), 'Language for https://stackoverflow.com is ok'); |
137 | 137 | ||
138 | $createdAt = $content->getCreatedAt(); | 138 | $createdAt = $content->getCreatedAt(); |
139 | $this->assertEquals('2013', $createdAt->format('Y')); | 139 | $this->assertEquals('2013', $createdAt->format('Y')); |
diff --git a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php index 3f6f2b9f..c2e5fdb7 100644 --- a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php | |||
@@ -121,7 +121,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase | |||
121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok'); | 121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok'); |
122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok'); | 122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok'); |
123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok'); | 123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok'); |
124 | $this->assertEquals(0, count($content->getTags())); | 124 | $this->assertEquals(1, count($content->getTags())); |
125 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 125 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
126 | } | 126 | } |
127 | 127 | ||
diff --git a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php index 75a7e332..96b32484 100644 --- a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php | |||
@@ -121,7 +121,7 @@ class PinboardControllerTest extends WallabagCoreTestCase | |||
121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://ma.ttias.be is ok'); | 121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://ma.ttias.be is ok'); |
122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://ma.ttias.be is ok'); | 122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://ma.ttias.be is ok'); |
123 | $this->assertNotEmpty($content->getLanguage(), 'Language for https://ma.ttias.be is ok'); | 123 | $this->assertNotEmpty($content->getLanguage(), 'Language for https://ma.ttias.be is ok'); |
124 | $this->assertEquals(2, count($content->getTags())); | 124 | $this->assertEquals(3, count($content->getTags())); |
125 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 125 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
126 | $this->assertEquals('2016-10-26', $content->getCreatedAt()->format('Y-m-d')); | 126 | $this->assertEquals('2016-10-26', $content->getCreatedAt()->format('Y-m-d')); |
127 | } | 127 | } |
diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php index acb61ca1..e6d33fe9 100644 --- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php | |||
@@ -121,7 +121,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.zataz.com is ok'); | 121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.zataz.com is ok'); |
122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.zataz.com is ok'); | 122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.zataz.com is ok'); |
123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.zataz.com is ok'); | 123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.zataz.com is ok'); |
124 | $this->assertEquals(0, count($content->getTags())); | 124 | $this->assertEquals(1, count($content->getTags())); |
125 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 125 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
126 | $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); | 126 | $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); |
127 | } | 127 | } |
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php index acc39997..0c7f97ed 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php | |||
@@ -129,7 +129,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
129 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok'); | 129 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok'); |
130 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok'); | 130 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok'); |
131 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok'); | 131 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok'); |
132 | $this->assertEquals(1, count($content->getTags())); | 132 | $this->assertEquals(2, count($content->getTags())); |
133 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 133 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
134 | } | 134 | } |
135 | 135 | ||
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php index 26e2f40b..556ab1bd 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php | |||
@@ -122,7 +122,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase | |||
122 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok'); | 122 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok'); |
123 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok'); | 123 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok'); |
124 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok'); | 124 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok'); |
125 | $this->assertEquals(0, count($content->getTags())); | 125 | $this->assertEquals(1, 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') |
@@ -135,7 +135,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase | |||
135 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.mediapart.fr is ok'); | 135 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.mediapart.fr is ok'); |
136 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.mediapart.fr is ok'); | 136 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.mediapart.fr is ok'); |
137 | $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.mediapart.fr is ok'); | 137 | $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.mediapart.fr is ok'); |
138 | $this->assertEquals(2, count($content->getTags())); | 138 | $this->assertEquals(3, count($content->getTags())); |
139 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 139 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
140 | $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); | 140 | $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); |
141 | } | 141 | } |
diff --git a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php index 6b3adda4..cec19534 100644 --- a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php | |||
@@ -17,6 +17,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase | |||
17 | protected $em; | 17 | protected $em; |
18 | protected $logHandler; | 18 | protected $logHandler; |
19 | protected $contentProxy; | 19 | protected $contentProxy; |
20 | protected $tagsAssigner; | ||
20 | 21 | ||
21 | private function getChromeImport($unsetUser = false, $dispatched = 0) | 22 | private function getChromeImport($unsetUser = false, $dispatched = 0) |
22 | { | 23 | { |
@@ -30,6 +31,10 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase | |||
30 | ->disableOriginalConstructor() | 31 | ->disableOriginalConstructor() |
31 | ->getMock(); | 32 | ->getMock(); |
32 | 33 | ||
34 | $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner') | ||
35 | ->disableOriginalConstructor() | ||
36 | ->getMock(); | ||
37 | |||
33 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') | 38 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') |
34 | ->disableOriginalConstructor() | 39 | ->disableOriginalConstructor() |
35 | ->getMock(); | 40 | ->getMock(); |
@@ -38,7 +43,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase | |||
38 | ->expects($this->exactly($dispatched)) | 43 | ->expects($this->exactly($dispatched)) |
39 | ->method('dispatch'); | 44 | ->method('dispatch'); |
40 | 45 | ||
41 | $wallabag = new ChromeImport($this->em, $this->contentProxy, $dispatcher); | 46 | $wallabag = new ChromeImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); |
42 | 47 | ||
43 | $this->logHandler = new TestHandler(); | 48 | $this->logHandler = new TestHandler(); |
44 | $logger = new Logger('test', [$this->logHandler]); | 49 | $logger = new Logger('test', [$this->logHandler]); |
diff --git a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php index b516fbc5..c186c820 100644 --- a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php | |||
@@ -17,6 +17,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase | |||
17 | protected $em; | 17 | protected $em; |
18 | protected $logHandler; | 18 | protected $logHandler; |
19 | protected $contentProxy; | 19 | protected $contentProxy; |
20 | protected $tagsAssigner; | ||
20 | 21 | ||
21 | private function getFirefoxImport($unsetUser = false, $dispatched = 0) | 22 | private function getFirefoxImport($unsetUser = false, $dispatched = 0) |
22 | { | 23 | { |
@@ -30,6 +31,10 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase | |||
30 | ->disableOriginalConstructor() | 31 | ->disableOriginalConstructor() |
31 | ->getMock(); | 32 | ->getMock(); |
32 | 33 | ||
34 | $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner') | ||
35 | ->disableOriginalConstructor() | ||
36 | ->getMock(); | ||
37 | |||
33 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') | 38 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') |
34 | ->disableOriginalConstructor() | 39 | ->disableOriginalConstructor() |
35 | ->getMock(); | 40 | ->getMock(); |
@@ -38,7 +43,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase | |||
38 | ->expects($this->exactly($dispatched)) | 43 | ->expects($this->exactly($dispatched)) |
39 | ->method('dispatch'); | 44 | ->method('dispatch'); |
40 | 45 | ||
41 | $wallabag = new FirefoxImport($this->em, $this->contentProxy, $dispatcher); | 46 | $wallabag = new FirefoxImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); |
42 | 47 | ||
43 | $this->logHandler = new TestHandler(); | 48 | $this->logHandler = new TestHandler(); |
44 | $logger = new Logger('test', [$this->logHandler]); | 49 | $logger = new Logger('test', [$this->logHandler]); |
diff --git a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php index e262a808..6777a02e 100644 --- a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php | |||
@@ -17,6 +17,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase | |||
17 | protected $em; | 17 | protected $em; |
18 | protected $logHandler; | 18 | protected $logHandler; |
19 | protected $contentProxy; | 19 | protected $contentProxy; |
20 | protected $tagsAssigner; | ||
20 | 21 | ||
21 | private function getInstapaperImport($unsetUser = false, $dispatched = 0) | 22 | private function getInstapaperImport($unsetUser = false, $dispatched = 0) |
22 | { | 23 | { |
@@ -30,6 +31,10 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase | |||
30 | ->disableOriginalConstructor() | 31 | ->disableOriginalConstructor() |
31 | ->getMock(); | 32 | ->getMock(); |
32 | 33 | ||
34 | $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner') | ||
35 | ->disableOriginalConstructor() | ||
36 | ->getMock(); | ||
37 | |||
33 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') | 38 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') |
34 | ->disableOriginalConstructor() | 39 | ->disableOriginalConstructor() |
35 | ->getMock(); | 40 | ->getMock(); |
@@ -38,7 +43,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase | |||
38 | ->expects($this->exactly($dispatched)) | 43 | ->expects($this->exactly($dispatched)) |
39 | ->method('dispatch'); | 44 | ->method('dispatch'); |
40 | 45 | ||
41 | $import = new InstapaperImport($this->em, $this->contentProxy, $dispatcher); | 46 | $import = new InstapaperImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); |
42 | 47 | ||
43 | $this->logHandler = new TestHandler(); | 48 | $this->logHandler = new TestHandler(); |
44 | $logger = new Logger('test', [$this->logHandler]); | 49 | $logger = new Logger('test', [$this->logHandler]); |
diff --git a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php index 141ece36..b81ebe15 100644 --- a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php | |||
@@ -23,6 +23,8 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
23 | protected $em; | 23 | protected $em; |
24 | protected $contentProxy; | 24 | protected $contentProxy; |
25 | protected $logHandler; | 25 | protected $logHandler; |
26 | protected $tagsAssigner; | ||
27 | protected $uow; | ||
26 | 28 | ||
27 | private function getPocketImport($consumerKey = 'ConsumerKey', $dispatched = 0) | 29 | private function getPocketImport($consumerKey = 'ConsumerKey', $dispatched = 0) |
28 | { | 30 | { |
@@ -37,6 +39,10 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
37 | ->disableOriginalConstructor() | 39 | ->disableOriginalConstructor() |
38 | ->getMock(); | 40 | ->getMock(); |
39 | 41 | ||
42 | $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner') | ||
43 | ->disableOriginalConstructor() | ||
44 | ->getMock(); | ||
45 | |||
40 | $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager') | 46 | $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager') |
41 | ->disableOriginalConstructor() | 47 | ->disableOriginalConstructor() |
42 | ->getMock(); | 48 | ->getMock(); |
@@ -63,7 +69,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase | |||
63 | ->expects($this->exactly($dispatched)) | 69 | ->expects($this->exactly($dispatched)) |
64 | ->method('dispatch'); | 70 | ->method('dispatch'); |
65 | 71 | ||
66 | $pocket = new PocketImport($this->em, $this->contentProxy, $dispatcher); | 72 | $pocket = new PocketImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); |
67 | $pocket->setUser($this->user); | 73 | $pocket->setUser($this->user); |
68 | 74 | ||
69 | $this->logHandler = new TestHandler(); | 75 | $this->logHandler = new TestHandler(); |
diff --git a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php index d1bbe648..254f0a25 100644 --- a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php | |||
@@ -17,6 +17,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
17 | protected $em; | 17 | protected $em; |
18 | protected $logHandler; | 18 | protected $logHandler; |
19 | protected $contentProxy; | 19 | protected $contentProxy; |
20 | protected $tagsAssigner; | ||
20 | 21 | ||
21 | private function getReadabilityImport($unsetUser = false, $dispatched = 0) | 22 | private function getReadabilityImport($unsetUser = false, $dispatched = 0) |
22 | { | 23 | { |
@@ -30,6 +31,10 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
30 | ->disableOriginalConstructor() | 31 | ->disableOriginalConstructor() |
31 | ->getMock(); | 32 | ->getMock(); |
32 | 33 | ||
34 | $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner') | ||
35 | ->disableOriginalConstructor() | ||
36 | ->getMock(); | ||
37 | |||
33 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') | 38 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') |
34 | ->disableOriginalConstructor() | 39 | ->disableOriginalConstructor() |
35 | ->getMock(); | 40 | ->getMock(); |
@@ -38,7 +43,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
38 | ->expects($this->exactly($dispatched)) | 43 | ->expects($this->exactly($dispatched)) |
39 | ->method('dispatch'); | 44 | ->method('dispatch'); |
40 | 45 | ||
41 | $wallabag = new ReadabilityImport($this->em, $this->contentProxy, $dispatcher); | 46 | $wallabag = new ReadabilityImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); |
42 | 47 | ||
43 | $this->logHandler = new TestHandler(); | 48 | $this->logHandler = new TestHandler(); |
44 | $logger = new Logger('test', [$this->logHandler]); | 49 | $logger = new Logger('test', [$this->logHandler]); |
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php index 4dbced60..9f0c5bac 100644 --- a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php | |||
@@ -17,6 +17,8 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase | |||
17 | protected $em; | 17 | protected $em; |
18 | protected $logHandler; | 18 | protected $logHandler; |
19 | protected $contentProxy; | 19 | protected $contentProxy; |
20 | protected $tagsAssigner; | ||
21 | protected $uow; | ||
20 | 22 | ||
21 | private function getWallabagV1Import($unsetUser = false, $dispatched = 0) | 23 | private function getWallabagV1Import($unsetUser = false, $dispatched = 0) |
22 | { | 24 | { |
@@ -44,6 +46,10 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase | |||
44 | ->disableOriginalConstructor() | 46 | ->disableOriginalConstructor() |
45 | ->getMock(); | 47 | ->getMock(); |
46 | 48 | ||
49 | $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner') | ||
50 | ->disableOriginalConstructor() | ||
51 | ->getMock(); | ||
52 | |||
47 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') | 53 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') |
48 | ->disableOriginalConstructor() | 54 | ->disableOriginalConstructor() |
49 | ->getMock(); | 55 | ->getMock(); |
@@ -52,7 +58,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase | |||
52 | ->expects($this->exactly($dispatched)) | 58 | ->expects($this->exactly($dispatched)) |
53 | ->method('dispatch'); | 59 | ->method('dispatch'); |
54 | 60 | ||
55 | $wallabag = new WallabagV1Import($this->em, $this->contentProxy, $dispatcher); | 61 | $wallabag = new WallabagV1Import($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); |
56 | 62 | ||
57 | $this->logHandler = new TestHandler(); | 63 | $this->logHandler = new TestHandler(); |
58 | $logger = new Logger('test', [$this->logHandler]); | 64 | $logger = new Logger('test', [$this->logHandler]); |
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php index 0e50b8b2..efcaeb9e 100644 --- a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php | |||
@@ -17,6 +17,8 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
17 | protected $em; | 17 | protected $em; |
18 | protected $logHandler; | 18 | protected $logHandler; |
19 | protected $contentProxy; | 19 | protected $contentProxy; |
20 | protected $tagsAssigner; | ||
21 | protected $uow; | ||
20 | 22 | ||
21 | private function getWallabagV2Import($unsetUser = false, $dispatched = 0) | 23 | private function getWallabagV2Import($unsetUser = false, $dispatched = 0) |
22 | { | 24 | { |
@@ -44,6 +46,10 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
44 | ->disableOriginalConstructor() | 46 | ->disableOriginalConstructor() |
45 | ->getMock(); | 47 | ->getMock(); |
46 | 48 | ||
49 | $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner') | ||
50 | ->disableOriginalConstructor() | ||
51 | ->getMock(); | ||
52 | |||
47 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') | 53 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') |
48 | ->disableOriginalConstructor() | 54 | ->disableOriginalConstructor() |
49 | ->getMock(); | 55 | ->getMock(); |
@@ -52,7 +58,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
52 | ->expects($this->exactly($dispatched)) | 58 | ->expects($this->exactly($dispatched)) |
53 | ->method('dispatch'); | 59 | ->method('dispatch'); |
54 | 60 | ||
55 | $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $dispatcher); | 61 | $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); |
56 | 62 | ||
57 | $this->logHandler = new TestHandler(); | 63 | $this->logHandler = new TestHandler(); |
58 | $logger = new Logger('test', [$this->logHandler]); | 64 | $logger = new Logger('test', [$this->logHandler]); |
diff --git a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php index 4faddfc4..44b9a030 100644 --- a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php +++ b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php | |||
@@ -10,7 +10,7 @@ class ManageControllerTest extends WallabagCoreTestCase | |||
10 | { | 10 | { |
11 | $client = $this->getClient(); | 11 | $client = $this->getClient(); |
12 | 12 | ||
13 | $client->request('GET', '/users/'); | 13 | $client->request('GET', '/users/list'); |
14 | 14 | ||
15 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 15 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
16 | $this->assertContains('login', $client->getResponse()->headers->get('location')); | 16 | $this->assertContains('login', $client->getResponse()->headers->get('location')); |
@@ -22,7 +22,7 @@ class ManageControllerTest extends WallabagCoreTestCase | |||
22 | $client = $this->getClient(); | 22 | $client = $this->getClient(); |
23 | 23 | ||
24 | // Create a new user in the database | 24 | // Create a new user in the database |
25 | $crawler = $client->request('GET', '/users/'); | 25 | $crawler = $client->request('GET', '/users/list'); |
26 | $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Unexpected HTTP status code for GET /users/'); | 26 | $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Unexpected HTTP status code for GET /users/'); |
27 | $crawler = $client->click($crawler->selectLink('user.list.create_new_one')->link()); | 27 | $crawler = $client->click($crawler->selectLink('user.list.create_new_one')->link()); |
28 | 28 | ||
@@ -36,7 +36,7 @@ class ManageControllerTest extends WallabagCoreTestCase | |||
36 | 36 | ||
37 | $client->submit($form); | 37 | $client->submit($form); |
38 | $client->followRedirect(); | 38 | $client->followRedirect(); |
39 | $crawler = $client->request('GET', '/users/'); | 39 | $crawler = $client->request('GET', '/users/list'); |
40 | 40 | ||
41 | // Check data in the show view | 41 | // Check data in the show view |
42 | $this->assertGreaterThan(0, $crawler->filter('td:contains("test_user")')->count(), 'Missing element td:contains("test_user")'); | 42 | $this->assertGreaterThan(0, $crawler->filter('td:contains("test_user")')->count(), 'Missing element td:contains("test_user")'); |
@@ -57,7 +57,7 @@ class ManageControllerTest extends WallabagCoreTestCase | |||
57 | // Check the element contains an attribute with value equals "Foo User" | 57 | // Check the element contains an attribute with value equals "Foo User" |
58 | $this->assertGreaterThan(0, $crawler->filter('[value="Foo User"]')->count(), 'Missing element [value="Foo User"]'); | 58 | $this->assertGreaterThan(0, $crawler->filter('[value="Foo User"]')->count(), 'Missing element [value="Foo User"]'); |
59 | 59 | ||
60 | $crawler = $client->request('GET', '/users/'); | 60 | $crawler = $client->request('GET', '/users/list'); |
61 | $crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link()); | 61 | $crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link()); |
62 | 62 | ||
63 | // Delete the user | 63 | // Delete the user |
@@ -78,4 +78,22 @@ class ManageControllerTest extends WallabagCoreTestCase | |||
78 | 78 | ||
79 | $this->assertEquals('disabled', $disabled[0]); | 79 | $this->assertEquals('disabled', $disabled[0]); |
80 | } | 80 | } |
81 | |||
82 | public function testUserSearch() | ||
83 | { | ||
84 | $this->logInAs('admin'); | ||
85 | $client = $this->getClient(); | ||
86 | |||
87 | // Search on unread list | ||
88 | $crawler = $client->request('GET', '/users/list'); | ||
89 | |||
90 | $form = $crawler->filter('form[name=search_users]')->form(); | ||
91 | $data = [ | ||
92 | 'search_user[term]' => 'admin', | ||
93 | ]; | ||
94 | |||
95 | $crawler = $client->submit($form, $data); | ||
96 | |||
97 | $this->assertCount(2, $crawler->filter('tr')); // 1 result + table header | ||
98 | } | ||
81 | } | 99 | } |