diff options
Diffstat (limited to 'tests')
18 files changed, 422 insertions, 50 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 63d70bd9..4f49f040 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -314,7 +314,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
314 | $entry = $this->client->getContainer() | 314 | $entry = $this->client->getContainer() |
315 | ->get('doctrine.orm.entity_manager') | 315 | ->get('doctrine.orm.entity_manager') |
316 | ->getRepository('WallabagCoreBundle:Entry') | 316 | ->getRepository('WallabagCoreBundle:Entry') |
317 | ->findOneByUser(1); | 317 | ->findOneByUser(1, ['id' => 'asc']); |
318 | 318 | ||
319 | if (!$entry) { | 319 | if (!$entry) { |
320 | $this->markTestSkipped('No content found in db.'); | 320 | $this->markTestSkipped('No content found in db.'); |
@@ -353,7 +353,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
353 | $this->assertEquals(false, $content['is_starred']); | 353 | $this->assertEquals(false, $content['is_starred']); |
354 | $this->assertEquals('New title for my article', $content['title']); | 354 | $this->assertEquals('New title for my article', $content['title']); |
355 | $this->assertEquals(1, $content['user_id']); | 355 | $this->assertEquals(1, $content['user_id']); |
356 | $this->assertCount(1, $content['tags']); | 356 | $this->assertCount(2, $content['tags']); |
357 | } | 357 | } |
358 | 358 | ||
359 | public function testPostSameEntry() | 359 | public function testPostSameEntry() |
@@ -372,7 +372,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
372 | $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']); | 372 | $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(true, $content['is_archived']); | 373 | $this->assertEquals(true, $content['is_archived']); |
374 | $this->assertEquals(false, $content['is_starred']); | 374 | $this->assertEquals(false, $content['is_starred']); |
375 | $this->assertCount(2, $content['tags']); | 375 | $this->assertCount(3, $content['tags']); |
376 | } | 376 | } |
377 | 377 | ||
378 | public function testPostArchivedAndStarredEntry() | 378 | public function testPostArchivedAndStarredEntry() |
@@ -658,7 +658,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
658 | 658 | ||
659 | $content = json_decode($this->client->getResponse()->getContent(), true); | 659 | $content = json_decode($this->client->getResponse()->getContent(), true); |
660 | 660 | ||
661 | $this->assertEquals(true, $content['exists']); | 661 | $this->assertEquals(2, $content['exists']); |
662 | } | 662 | } |
663 | 663 | ||
664 | public function testGetEntriesExistsWithManyUrls() | 664 | public function testGetEntriesExistsWithManyUrls() |
@@ -673,7 +673,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
673 | 673 | ||
674 | $this->assertArrayHasKey($url1, $content); | 674 | $this->assertArrayHasKey($url1, $content); |
675 | $this->assertArrayHasKey($url2, $content); | 675 | $this->assertArrayHasKey($url2, $content); |
676 | $this->assertEquals(true, $content[$url1]); | 676 | $this->assertEquals(2, $content[$url1]); |
677 | $this->assertEquals(false, $content[$url2]); | 677 | $this->assertEquals(false, $content[$url2]); |
678 | } | 678 | } |
679 | 679 | ||
@@ -730,4 +730,120 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
730 | 730 | ||
731 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); | 731 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
732 | } | 732 | } |
733 | |||
734 | public function testPostEntriesTagsListAction() | ||
735 | { | ||
736 | $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') | ||
737 | ->getRepository('WallabagCoreBundle:Entry') | ||
738 | ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); | ||
739 | |||
740 | $tags = $entry->getTags(); | ||
741 | |||
742 | $this->assertCount(2, $tags); | ||
743 | |||
744 | $list = [ | ||
745 | [ | ||
746 | 'url' => 'http://0.0.0.0/entry4', | ||
747 | 'tags' => 'new tag 1, new tag 2', | ||
748 | ], | ||
749 | ]; | ||
750 | |||
751 | $this->client->request('POST', '/api/entries/tags/lists?list='.json_encode($list)); | ||
752 | |||
753 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
754 | |||
755 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
756 | |||
757 | $this->assertInternalType('int', $content[0]['entry']); | ||
758 | $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']); | ||
759 | |||
760 | $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') | ||
761 | ->getRepository('WallabagCoreBundle:Entry') | ||
762 | ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); | ||
763 | |||
764 | $tags = $entry->getTags(); | ||
765 | $this->assertCount(4, $tags); | ||
766 | } | ||
767 | |||
768 | public function testDeleteEntriesTagsListAction() | ||
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(4, $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('DELETE', '/api/entries/tags/list?list='.json_encode($list)); | ||
786 | } | ||
787 | |||
788 | public function testPostEntriesListAction() | ||
789 | { | ||
790 | $list = [ | ||
791 | 'http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', | ||
792 | 'http://0.0.0.0/entry2', | ||
793 | ]; | ||
794 | |||
795 | $this->client->request('POST', '/api/entries/lists?urls='.json_encode($list)); | ||
796 | |||
797 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
798 | |||
799 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
800 | |||
801 | $this->assertInternalType('int', $content[0]['entry']); | ||
802 | $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']); | ||
803 | |||
804 | $this->assertInternalType('int', $content[1]['entry']); | ||
805 | $this->assertEquals('http://0.0.0.0/entry2', $content[1]['url']); | ||
806 | } | ||
807 | |||
808 | public function testDeleteEntriesListAction() | ||
809 | { | ||
810 | $list = [ | ||
811 | 'http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', | ||
812 | 'http://0.0.0.0/entry3', | ||
813 | ]; | ||
814 | |||
815 | $this->client->request('DELETE', '/api/entries/list?urls='.json_encode($list)); | ||
816 | |||
817 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
818 | |||
819 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
820 | |||
821 | $this->assertTrue($content[0]['entry']); | ||
822 | $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']); | ||
823 | |||
824 | $this->assertFalse($content[1]['entry']); | ||
825 | $this->assertEquals('http://0.0.0.0/entry3', $content[1]['url']); | ||
826 | } | ||
827 | |||
828 | public function testLimitBulkAction() | ||
829 | { | ||
830 | $list = [ | ||
831 | 'http://0.0.0.0/entry1', | ||
832 | 'http://0.0.0.0/entry1', | ||
833 | 'http://0.0.0.0/entry1', | ||
834 | 'http://0.0.0.0/entry1', | ||
835 | 'http://0.0.0.0/entry1', | ||
836 | 'http://0.0.0.0/entry1', | ||
837 | 'http://0.0.0.0/entry1', | ||
838 | 'http://0.0.0.0/entry1', | ||
839 | 'http://0.0.0.0/entry1', | ||
840 | 'http://0.0.0.0/entry1', | ||
841 | 'http://0.0.0.0/entry1', | ||
842 | ]; | ||
843 | |||
844 | $this->client->request('POST', '/api/entries/lists?urls='.json_encode($list)); | ||
845 | |||
846 | $this->assertEquals(400, $this->client->getResponse()->getStatusCode()); | ||
847 | $this->assertContains('API limit reached', $this->client->getResponse()->getContent()); | ||
848 | } | ||
733 | } | 849 | } |
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 3eb6d47f..35438c83 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -135,9 +135,44 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
135 | ->getRepository('WallabagCoreBundle:Entry') | 135 | ->getRepository('WallabagCoreBundle:Entry') |
136 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | 136 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
137 | 137 | ||
138 | $author = $content->getPublishedBy(); | ||
139 | |||
138 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); | 140 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); |
139 | $this->assertEquals($this->url, $content->getUrl()); | 141 | $this->assertEquals($this->url, $content->getUrl()); |
140 | $this->assertContains('Google', $content->getTitle()); | 142 | $this->assertContains('Google', $content->getTitle()); |
143 | $this->assertEquals('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s')); | ||
144 | $this->assertEquals('Morgane Tual', $author[0]); | ||
145 | } | ||
146 | |||
147 | public function testPostWithMultipleAuthors() | ||
148 | { | ||
149 | $url = 'http://www.liberation.fr/planete/2017/04/05/donald-trump-et-xi-jinping-tentative-de-flirt-en-floride_1560768'; | ||
150 | $this->logInAs('admin'); | ||
151 | $client = $this->getClient(); | ||
152 | |||
153 | $crawler = $client->request('GET', '/new'); | ||
154 | |||
155 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
156 | |||
157 | $form = $crawler->filter('form[name=entry]')->form(); | ||
158 | |||
159 | $data = [ | ||
160 | 'entry[url]' => $url, | ||
161 | ]; | ||
162 | |||
163 | $client->submit($form, $data); | ||
164 | |||
165 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
166 | |||
167 | $content = $client->getContainer() | ||
168 | ->get('doctrine.orm.entity_manager') | ||
169 | ->getRepository('WallabagCoreBundle:Entry') | ||
170 | ->findByUrlAndUserId($url, $this->getLoggedInUserId()); | ||
171 | |||
172 | $authors = $content->getPublishedBy(); | ||
173 | $this->assertEquals('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s')); | ||
174 | $this->assertEquals('Raphaël Balenieri, correspondant à Pékin', $authors[0]); | ||
175 | $this->assertEquals('Frédéric Autran, correspondant à New York', $authors[1]); | ||
141 | } | 176 | } |
142 | 177 | ||
143 | public function testPostNewOkUrlExist() | 178 | public function testPostNewOkUrlExist() |
@@ -235,7 +270,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
235 | ->findOneByUrl($url); | 270 | ->findOneByUrl($url); |
236 | $tags = $entry->getTags(); | 271 | $tags = $entry->getTags(); |
237 | 272 | ||
238 | $this->assertCount(1, $tags); | 273 | $this->assertCount(2, $tags); |
239 | $this->assertEquals('wallabag', $tags[0]->getLabel()); | 274 | $this->assertEquals('wallabag', $tags[0]->getLabel()); |
240 | 275 | ||
241 | $em->remove($entry); | 276 | $em->remove($entry); |
@@ -264,8 +299,8 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
264 | 299 | ||
265 | $tags = $entry->getTags(); | 300 | $tags = $entry->getTags(); |
266 | 301 | ||
267 | $this->assertCount(1, $tags); | 302 | $this->assertCount(2, $tags); |
268 | $this->assertEquals('wallabag', $tags[0]->getLabel()); | 303 | $this->assertEquals('wallabag', $tags[1]->getLabel()); |
269 | 304 | ||
270 | $em->remove($entry); | 305 | $em->remove($entry); |
271 | $em->flush(); | 306 | $em->flush(); |
@@ -606,7 +641,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
606 | 641 | ||
607 | $crawler = $client->submit($form, $data); | 642 | $crawler = $client->submit($form, $data); |
608 | 643 | ||
609 | $this->assertCount(2, $crawler->filter('div[class=entry]')); | 644 | $this->assertCount(3, $crawler->filter('div[class=entry]')); |
610 | } | 645 | } |
611 | 646 | ||
612 | public function testFilterOnReadingTimeOnlyLower() | 647 | public function testFilterOnReadingTimeOnlyLower() |
@@ -642,7 +677,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
642 | 677 | ||
643 | $crawler = $client->submit($form, $data); | 678 | $crawler = $client->submit($form, $data); |
644 | 679 | ||
645 | $this->assertCount(4, $crawler->filter('div[class=entry]')); | 680 | $this->assertCount(5, $crawler->filter('div[class=entry]')); |
646 | } | 681 | } |
647 | 682 | ||
648 | public function testFilterOnCreationDate() | 683 | public function testFilterOnCreationDate() |
@@ -661,7 +696,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
661 | 696 | ||
662 | $crawler = $client->submit($form, $data); | 697 | $crawler = $client->submit($form, $data); |
663 | 698 | ||
664 | $this->assertCount(5, $crawler->filter('div[class=entry]')); | 699 | $this->assertCount(6, $crawler->filter('div[class=entry]')); |
665 | 700 | ||
666 | $data = [ | 701 | $data = [ |
667 | 'entry_filter[createdAt][left_date]' => date('d/m/Y'), | 702 | 'entry_filter[createdAt][left_date]' => date('d/m/Y'), |
@@ -670,7 +705,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
670 | 705 | ||
671 | $crawler = $client->submit($form, $data); | 706 | $crawler = $client->submit($form, $data); |
672 | 707 | ||
673 | $this->assertCount(5, $crawler->filter('div[class=entry]')); | 708 | $this->assertCount(6, $crawler->filter('div[class=entry]')); |
674 | 709 | ||
675 | $data = [ | 710 | $data = [ |
676 | 'entry_filter[createdAt][left_date]' => '01/01/1970', | 711 | 'entry_filter[createdAt][left_date]' => '01/01/1970', |
@@ -774,7 +809,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
774 | $form['entry_filter[previewPicture]']->tick(); | 809 | $form['entry_filter[previewPicture]']->tick(); |
775 | 810 | ||
776 | $crawler = $client->submit($form); | 811 | $crawler = $client->submit($form); |
777 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | 812 | $this->assertCount(2, $crawler->filter('div[class=entry]')); |
778 | } | 813 | } |
779 | 814 | ||
780 | public function testFilterOnLanguage() | 815 | public function testFilterOnLanguage() |
@@ -789,7 +824,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
789 | ]; | 824 | ]; |
790 | 825 | ||
791 | $crawler = $client->submit($form, $data); | 826 | $crawler = $client->submit($form, $data); |
792 | $this->assertCount(2, $crawler->filter('div[class=entry]')); | 827 | $this->assertCount(3, $crawler->filter('div[class=entry]')); |
793 | 828 | ||
794 | $form = $crawler->filter('button[id=submit-filter]')->form(); | 829 | $form = $crawler->filter('button[id=submit-filter]')->form(); |
795 | $data = [ | 830 | $data = [ |
@@ -1014,7 +1049,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1014 | 1049 | ||
1015 | $crawler = $client->submit($form, $data); | 1050 | $crawler = $client->submit($form, $data); |
1016 | 1051 | ||
1017 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | 1052 | $this->assertCount(2, $crawler->filter('div[class=entry]')); |
1018 | 1053 | ||
1019 | $crawler = $client->request('GET', '/all/list'); | 1054 | $crawler = $client->request('GET', '/all/list'); |
1020 | $form = $crawler->filter('button[id=submit-filter]')->form(); | 1055 | $form = $crawler->filter('button[id=submit-filter]')->form(); |
@@ -1025,7 +1060,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1025 | 1060 | ||
1026 | $crawler = $client->submit($form, $data); | 1061 | $crawler = $client->submit($form, $data); |
1027 | 1062 | ||
1028 | $this->assertCount(7, $crawler->filter('div[class=entry]')); | 1063 | $this->assertCount(8, $crawler->filter('div[class=entry]')); |
1029 | } | 1064 | } |
1030 | 1065 | ||
1031 | public function testSearch() | 1066 | 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/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php index 5956b502..8abb1bbb 100644 --- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | |||
@@ -111,7 +111,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
111 | 111 | ||
112 | $this->assertEquals('http://domain.io', $entry->getUrl()); | 112 | $this->assertEquals('http://domain.io', $entry->getUrl()); |
113 | $this->assertEquals('my title', $entry->getTitle()); | 113 | $this->assertEquals('my title', $entry->getTitle()); |
114 | $this->assertEquals($this->fetchingErrorMessage . '<p><i>But we found a short description: </i></p>desc', $entry->getContent()); | 114 | $this->assertEquals($this->fetchingErrorMessage.'<p><i>But we found a short description: </i></p>desc', $entry->getContent()); |
115 | $this->assertEmpty($entry->getPreviewPicture()); | 115 | $this->assertEmpty($entry->getPreviewPicture()); |
116 | $this->assertEmpty($entry->getLanguage()); | 116 | $this->assertEmpty($entry->getLanguage()); |
117 | $this->assertEmpty($entry->getHttpStatus()); | 117 | $this->assertEmpty($entry->getHttpStatus()); |
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..68453027 100644 --- a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php | |||
@@ -121,7 +121,7 @@ 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') |
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/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 | } |