aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php3
-rw-r--r--tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php4
-rw-r--r--tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php2
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php86
-rw-r--r--tests/Wallabag/ApiBundle/WallabagApiTestCase.php23
-rw-r--r--tests/Wallabag/CoreBundle/Command/InstallCommandTest.php18
-rw-r--r--tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php6
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php37
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php20
-rw-r--r--tests/Wallabag/CoreBundle/Controller/TagControllerTest.php45
-rw-r--r--tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php23
-rw-r--r--tests/Wallabag/CoreBundle/WallabagCoreTestCase.php4
-rw-r--r--tests/Wallabag/ImportBundle/Command/ImportCommandTest.php4
-rw-r--r--tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php6
14 files changed, 208 insertions, 73 deletions
diff --git a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
index 96474468..537283f2 100644
--- a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
+++ b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
@@ -100,8 +100,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
100 $this->assertSame('my quote', $content['quote']); 100 $this->assertSame('my quote', $content['quote']);
101 101
102 /** @var Annotation $annotation */ 102 /** @var Annotation $annotation */
103 $annotation = $this->client->getContainer() 103 $annotation = $em
104 ->get('doctrine.orm.entity_manager')
105 ->getRepository('WallabagAnnotationBundle:Annotation') 104 ->getRepository('WallabagAnnotationBundle:Annotation')
106 ->findLastAnnotationByPageId($entry->getId(), 1); 105 ->findLastAnnotationByPageId($entry->getId(), 1);
107 106
diff --git a/tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php b/tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php
index 105e8add..9c7aba6b 100644
--- a/tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php
+++ b/tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php
@@ -43,9 +43,9 @@ abstract class WallabagAnnotationTestCase extends WebTestCase
43 $container = $client->getContainer(); 43 $container = $client->getContainer();
44 44
45 /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */ 45 /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
46 $userManager = $container->get('fos_user.user_manager'); 46 $userManager = $container->get('fos_user.user_manager.test');
47 /** @var $loginManager \FOS\UserBundle\Security\LoginManager */ 47 /** @var $loginManager \FOS\UserBundle\Security\LoginManager */
48 $loginManager = $container->get('fos_user.security.login_manager'); 48 $loginManager = $container->get('fos_user.security.login_manager.test');
49 $firewallName = $container->getParameter('fos_user.firewall_name'); 49 $firewallName = $container->getParameter('fos_user.firewall_name');
50 50
51 $this->user = $userManager->findUserBy(['username' => 'admin']); 51 $this->user = $userManager->findUserBy(['username' => 'admin']);
diff --git a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php
index e1a0ac7e..5586c70d 100644
--- a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php
@@ -135,7 +135,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase
135 { 135 {
136 $client = $this->getClient(); 136 $client = $this->getClient();
137 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 137 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
138 $userManager = $client->getContainer()->get('fos_user.user_manager'); 138 $userManager = $client->getContainer()->get('fos_user.user_manager.test');
139 $user = $userManager->findUserBy(['username' => $username]); 139 $user = $userManager->findUserBy(['username' => $username]);
140 $apiClient = new Client($user); 140 $apiClient = new Client($user);
141 $apiClient->setName('My app'); 141 $apiClient->setName('My app');
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index 2a1d2e15..1a41338c 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -15,7 +15,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
15 $entry = $this->client->getContainer() 15 $entry = $this->client->getContainer()
16 ->get('doctrine.orm.entity_manager') 16 ->get('doctrine.orm.entity_manager')
17 ->getRepository('WallabagCoreBundle:Entry') 17 ->getRepository('WallabagCoreBundle:Entry')
18 ->findOneBy(['user' => 1, 'isArchived' => false]); 18 ->findOneBy(['user' => $this->getUserId(), 'isArchived' => false]);
19 19
20 if (!$entry) { 20 if (!$entry) {
21 $this->markTestSkipped('No content found in db.'); 21 $this->markTestSkipped('No content found in db.');
@@ -41,7 +41,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
41 $entry = $this->client->getContainer() 41 $entry = $this->client->getContainer()
42 ->get('doctrine.orm.entity_manager') 42 ->get('doctrine.orm.entity_manager')
43 ->getRepository('WallabagCoreBundle:Entry') 43 ->getRepository('WallabagCoreBundle:Entry')
44 ->findOneBy(['user' => 1, 'url' => 'http://0.0.0.0/entry2']); 44 ->findOneBy(['user' => $this->getUserId(), 'url' => 'http://0.0.0.0/entry2']);
45 45
46 if (!$entry) { 46 if (!$entry) {
47 $this->markTestSkipped('No content found in db.'); 47 $this->markTestSkipped('No content found in db.');
@@ -60,7 +60,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
60 $entry = $this->client->getContainer() 60 $entry = $this->client->getContainer()
61 ->get('doctrine.orm.entity_manager') 61 ->get('doctrine.orm.entity_manager')
62 ->getRepository('WallabagCoreBundle:Entry') 62 ->getRepository('WallabagCoreBundle:Entry')
63 ->findOneBy(['user' => 1, 'isArchived' => false]); 63 ->findOneBy(['user' => $this->getUserId(), 'isArchived' => false]);
64 64
65 if (!$entry) { 65 if (!$entry) {
66 $this->markTestSkipped('No content found in db.'); 66 $this->markTestSkipped('No content found in db.');
@@ -108,7 +108,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
108 $entry = $this->client->getContainer() 108 $entry = $this->client->getContainer()
109 ->get('doctrine.orm.entity_manager') 109 ->get('doctrine.orm.entity_manager')
110 ->getRepository('WallabagCoreBundle:Entry') 110 ->getRepository('WallabagCoreBundle:Entry')
111 ->findOneBy(['user' => 2, 'isArchived' => false]); 111 ->findOneBy(['user' => $this->getUserId('bob'), 'isArchived' => false]);
112 112
113 if (!$entry) { 113 if (!$entry) {
114 $this->markTestSkipped('No content found in db.'); 114 $this->markTestSkipped('No content found in db.');
@@ -185,7 +185,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
185 $entry = $this->client->getContainer() 185 $entry = $this->client->getContainer()
186 ->get('doctrine.orm.entity_manager') 186 ->get('doctrine.orm.entity_manager')
187 ->getRepository('WallabagCoreBundle:Entry') 187 ->getRepository('WallabagCoreBundle:Entry')
188 ->findOneByUser(1); 188 ->findOneByUser($this->getUserId());
189 189
190 if (!$entry) { 190 if (!$entry) {
191 $this->markTestSkipped('No content found in db.'); 191 $this->markTestSkipped('No content found in db.');
@@ -403,7 +403,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
403 $entry = $this->client->getContainer() 403 $entry = $this->client->getContainer()
404 ->get('doctrine.orm.entity_manager') 404 ->get('doctrine.orm.entity_manager')
405 ->getRepository('WallabagCoreBundle:Entry') 405 ->getRepository('WallabagCoreBundle:Entry')
406 ->findOneByUser(1, ['id' => 'asc']); 406 ->findOneByUser($this->getUserId(), ['id' => 'asc']);
407 407
408 if (!$entry) { 408 if (!$entry) {
409 $this->markTestSkipped('No content found in db.'); 409 $this->markTestSkipped('No content found in db.');
@@ -447,8 +447,9 @@ class EntryRestControllerTest extends WallabagApiTestCase
447 $this->assertSame(0, $content['is_archived']); 447 $this->assertSame(0, $content['is_archived']);
448 $this->assertSame(0, $content['is_starred']); 448 $this->assertSame(0, $content['is_starred']);
449 $this->assertNull($content['starred_at']); 449 $this->assertNull($content['starred_at']);
450 $this->assertNull($content['archived_at']);
450 $this->assertSame('New title for my article', $content['title']); 451 $this->assertSame('New title for my article', $content['title']);
451 $this->assertSame(1, $content['user_id']); 452 $this->assertSame($this->getUserId(), $content['user_id']);
452 $this->assertCount(2, $content['tags']); 453 $this->assertCount(2, $content['tags']);
453 $this->assertNull($content['origin_url']); 454 $this->assertNull($content['origin_url']);
454 $this->assertSame('my content', $content['content']); 455 $this->assertSame('my content', $content['content']);
@@ -463,7 +464,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
463 public function testPostSameEntry() 464 public function testPostSameEntry()
464 { 465 {
465 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); 466 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
466 $entry = new Entry($em->getReference(User::class, 1)); 467 $entry = new Entry($em->getReference(User::class, $this->getUserId()));
467 $entry->setUrl('https://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'); 468 $entry->setUrl('https://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');
468 $entry->setArchived(true); 469 $entry->setArchived(true);
469 $entry->addTag((new Tag())->setLabel('google')); 470 $entry->addTag((new Tag())->setLabel('google'));
@@ -542,7 +543,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
542 $this->assertSame(1, $content['is_archived']); 543 $this->assertSame(1, $content['is_archived']);
543 $this->assertSame(1, $content['is_starred']); 544 $this->assertSame(1, $content['is_starred']);
544 $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['starred_at']))->getTimestamp()); 545 $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['starred_at']))->getTimestamp());
545 $this->assertSame(1, $content['user_id']); 546 $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['archived_at']))->getTimestamp());
547 $this->assertSame($this->getUserId(), $content['user_id']);
546 } 548 }
547 549
548 public function testPostArchivedAndStarredEntryWithoutQuotes() 550 public function testPostArchivedAndStarredEntryWithoutQuotes()
@@ -591,7 +593,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
591 $entry = $this->client->getContainer() 593 $entry = $this->client->getContainer()
592 ->get('doctrine.orm.entity_manager') 594 ->get('doctrine.orm.entity_manager')
593 ->getRepository('WallabagCoreBundle:Entry') 595 ->getRepository('WallabagCoreBundle:Entry')
594 ->findOneByUser(1); 596 ->findOneByUser($this->getUserId());
595 597
596 if (!$entry) { 598 if (!$entry) {
597 $this->markTestSkipped('No content found in db.'); 599 $this->markTestSkipped('No content found in db.');
@@ -618,7 +620,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
618 $this->assertSame($entry->getUrl(), $content['url']); 620 $this->assertSame($entry->getUrl(), $content['url']);
619 $this->assertSame('New awesome title', $content['title']); 621 $this->assertSame('New awesome title', $content['title']);
620 $this->assertGreaterThanOrEqual(1, \count($content['tags']), 'We force only one tag'); 622 $this->assertGreaterThanOrEqual(1, \count($content['tags']), 'We force only one tag');
621 $this->assertSame(1, $content['user_id']); 623 $this->assertSame($this->getUserId(), $content['user_id']);
622 $this->assertSame('de_AT', $content['language']); 624 $this->assertSame('de_AT', $content['language']);
623 $this->assertSame('http://preview.io/picture.jpg', $content['preview_picture']); 625 $this->assertSame('http://preview.io/picture.jpg', $content['preview_picture']);
624 $this->assertContains('sponge', $content['published_by']); 626 $this->assertContains('sponge', $content['published_by']);
@@ -633,7 +635,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
633 $entry = $this->client->getContainer() 635 $entry = $this->client->getContainer()
634 ->get('doctrine.orm.entity_manager') 636 ->get('doctrine.orm.entity_manager')
635 ->getRepository('WallabagCoreBundle:Entry') 637 ->getRepository('WallabagCoreBundle:Entry')
636 ->findOneByUser(1); 638 ->findOneByUser($this->getUserId());
637 639
638 if (!$entry) { 640 if (!$entry) {
639 $this->markTestSkipped('No content found in db.'); 641 $this->markTestSkipped('No content found in db.');
@@ -667,7 +669,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
667 $entry = $this->client->getContainer() 669 $entry = $this->client->getContainer()
668 ->get('doctrine.orm.entity_manager') 670 ->get('doctrine.orm.entity_manager')
669 ->getRepository('WallabagCoreBundle:Entry') 671 ->getRepository('WallabagCoreBundle:Entry')
670 ->findOneByUser(1); 672 ->findOneByUser($this->getUserId());
671 673
672 if (!$entry) { 674 if (!$entry) {
673 $this->markTestSkipped('No content found in db.'); 675 $this->markTestSkipped('No content found in db.');
@@ -698,7 +700,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
698 $entry = $this->client->getContainer() 700 $entry = $this->client->getContainer()
699 ->get('doctrine.orm.entity_manager') 701 ->get('doctrine.orm.entity_manager')
700 ->getRepository('WallabagCoreBundle:Entry') 702 ->getRepository('WallabagCoreBundle:Entry')
701 ->findOneByUser(1); 703 ->findOneByUser($this->getUserId());
702 704
703 if (!$entry) { 705 if (!$entry) {
704 $this->markTestSkipped('No content found in db.'); 706 $this->markTestSkipped('No content found in db.');
@@ -730,7 +732,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
730 $entry = $this->client->getContainer() 732 $entry = $this->client->getContainer()
731 ->get('doctrine.orm.entity_manager') 733 ->get('doctrine.orm.entity_manager')
732 ->getRepository('WallabagCoreBundle:Entry') 734 ->getRepository('WallabagCoreBundle:Entry')
733 ->findOneByUser(1); 735 ->findOneByUser($this->getUserId());
734 736
735 if (!$entry) { 737 if (!$entry) {
736 $this->markTestSkipped('No content found in db.'); 738 $this->markTestSkipped('No content found in db.');
@@ -775,7 +777,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
775 $entry = $this->client->getContainer() 777 $entry = $this->client->getContainer()
776 ->get('doctrine.orm.entity_manager') 778 ->get('doctrine.orm.entity_manager')
777 ->getRepository('WallabagCoreBundle:Entry') 779 ->getRepository('WallabagCoreBundle:Entry')
778 ->findOneByUser(1); 780 ->findOneByUser($this->getUserId());
779 781
780 if (!$entry) { 782 if (!$entry) {
781 $this->markTestSkipped('No content found in db.'); 783 $this->markTestSkipped('No content found in db.');
@@ -840,7 +842,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
840 $entry = $this->client->getContainer() 842 $entry = $this->client->getContainer()
841 ->get('doctrine.orm.entity_manager') 843 ->get('doctrine.orm.entity_manager')
842 ->getRepository('WallabagCoreBundle:Entry') 844 ->getRepository('WallabagCoreBundle:Entry')
843 ->findOneBy(['user' => 1, 'isArchived' => true]); 845 ->findOneBy(['user' => $this->getUserId(), 'isArchived' => true]);
844 846
845 if (!$entry) { 847 if (!$entry) {
846 $this->markTestSkipped('No content found in db.'); 848 $this->markTestSkipped('No content found in db.');
@@ -862,7 +864,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
862 $entry = $this->client->getContainer() 864 $entry = $this->client->getContainer()
863 ->get('doctrine.orm.entity_manager') 865 ->get('doctrine.orm.entity_manager')
864 ->getRepository('WallabagCoreBundle:Entry') 866 ->getRepository('WallabagCoreBundle:Entry')
865 ->findOneBy(['user' => 1, 'isStarred' => true]); 867 ->findOneBy(['user' => $this->getUserId(), 'isStarred' => true]);
866 868
867 if (!$entry) { 869 if (!$entry) {
868 $this->markTestSkipped('No content found in db.'); 870 $this->markTestSkipped('No content found in db.');
@@ -884,7 +886,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
884 $entry = $this->client->getContainer() 886 $entry = $this->client->getContainer()
885 ->get('doctrine.orm.entity_manager') 887 ->get('doctrine.orm.entity_manager')
886 ->getRepository('WallabagCoreBundle:Entry') 888 ->getRepository('WallabagCoreBundle:Entry')
887 ->findOneBy(['user' => 1, 'isArchived' => true]); 889 ->findOneBy(['user' => $this->getUserId(), 'isArchived' => true]);
888 890
889 if (!$entry) { 891 if (!$entry) {
890 $this->markTestSkipped('No content found in db.'); 892 $this->markTestSkipped('No content found in db.');
@@ -910,7 +912,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
910 $entry = $this->client->getContainer() 912 $entry = $this->client->getContainer()
911 ->get('doctrine.orm.entity_manager') 913 ->get('doctrine.orm.entity_manager')
912 ->getRepository('WallabagCoreBundle:Entry') 914 ->getRepository('WallabagCoreBundle:Entry')
913 ->findOneBy(['user' => 1, 'isStarred' => true]); 915 ->findOneBy(['user' => $this->getUserId(), 'isStarred' => true]);
914 916
915 if (!$entry) { 917 if (!$entry) {
916 $this->markTestSkipped('No content found in db.'); 918 $this->markTestSkipped('No content found in db.');
@@ -927,32 +929,27 @@ class EntryRestControllerTest extends WallabagApiTestCase
927 $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['starred_at']))->getTimestamp()); 929 $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['starred_at']))->getTimestamp());
928 } 930 }
929 931
930 public function dataForEntriesExistWithUrl() 932 public function testGetEntriesExistsWithReturnId()
931 { 933 {
932 return [ 934 $this->client->request('GET', '/api/entries/exists?url=http://0.0.0.0/entry2&return_id=1');
933 'with_id' => [ 935
934 'url' => '/api/entries/exists?url=http://0.0.0.0/entry2&return_id=1', 936 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
935 'expectedValue' => 2, 937
936 ], 938 $content = json_decode($this->client->getResponse()->getContent(), true);
937 'without_id' => [ 939
938 'url' => '/api/entries/exists?url=http://0.0.0.0/entry2', 940 // it returns a database id, we don't know it, so we only check it's greater than the lowest possible value
939 'expectedValue' => true, 941 $this->assertGreaterThan(1, $content['exists']);
940 ],
941 ];
942 } 942 }
943 943
944 /** 944 public function testGetEntriesExistsWithoutReturnId()
945 * @dataProvider dataForEntriesExistWithUrl
946 */
947 public function testGetEntriesExists($url, $expectedValue)
948 { 945 {
949 $this->client->request('GET', $url); 946 $this->client->request('GET', '/api/entries/exists?url=http://0.0.0.0/entry2');
950 947
951 $this->assertSame(200, $this->client->getResponse()->getStatusCode()); 948 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
952 949
953 $content = json_decode($this->client->getResponse()->getContent(), true); 950 $content = json_decode($this->client->getResponse()->getContent(), true);
954 951
955 $this->assertSame($expectedValue, $content['exists']); 952 $this->assertTrue($content['exists']);
956 } 953 }
957 954
958 public function testGetEntriesExistsWithManyUrls() 955 public function testGetEntriesExistsWithManyUrls()
@@ -967,7 +964,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
967 964
968 $this->assertArrayHasKey($url1, $content); 965 $this->assertArrayHasKey($url1, $content);
969 $this->assertArrayHasKey($url2, $content); 966 $this->assertArrayHasKey($url2, $content);
970 $this->assertSame(2, $content[$url1]); 967 // it returns a database id, we don't know it, so we only check it's greater than the lowest possible value
968 $this->assertGreaterThan(1, $content[$url1]);
971 $this->assertNull($content[$url2]); 969 $this->assertNull($content[$url2]);
972 } 970 }
973 971
@@ -1009,7 +1007,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
1009 { 1007 {
1010 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') 1008 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
1011 ->getRepository('WallabagCoreBundle:Entry') 1009 ->getRepository('WallabagCoreBundle:Entry')
1012 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); 1010 ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getUserId());
1013 1011
1014 if (!$entry) { 1012 if (!$entry) {
1015 $this->markTestSkipped('No content found in db.'); 1013 $this->markTestSkipped('No content found in db.');
@@ -1045,7 +1043,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
1045 { 1043 {
1046 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') 1044 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
1047 ->getRepository('WallabagCoreBundle:Entry') 1045 ->getRepository('WallabagCoreBundle:Entry')
1048 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); 1046 ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getUserId());
1049 1047
1050 $tags = $entry->getTags(); 1048 $tags = $entry->getTags();
1051 1049
@@ -1069,7 +1067,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
1069 1067
1070 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') 1068 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
1071 ->getRepository('WallabagCoreBundle:Entry') 1069 ->getRepository('WallabagCoreBundle:Entry')
1072 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); 1070 ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getUserId());
1073 1071
1074 $tags = $entry->getTags(); 1072 $tags = $entry->getTags();
1075 $this->assertCount(4, $tags); 1073 $this->assertCount(4, $tags);
@@ -1089,7 +1087,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
1089 public function testDeleteEntriesTagsListAction() 1087 public function testDeleteEntriesTagsListAction()
1090 { 1088 {
1091 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); 1089 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
1092 $entry = new Entry($em->getReference(User::class, 1)); 1090 $entry = new Entry($em->getReference(User::class, $this->getUserId()));
1093 $entry->setUrl('http://0.0.0.0/test-entry'); 1091 $entry->setUrl('http://0.0.0.0/test-entry');
1094 $entry->addTag((new Tag())->setLabel('foo-tag')); 1092 $entry->addTag((new Tag())->setLabel('foo-tag'));
1095 $entry->addTag((new Tag())->setLabel('bar-tag')); 1093 $entry->addTag((new Tag())->setLabel('bar-tag'));
@@ -1157,7 +1155,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
1157 public function testDeleteEntriesListAction() 1155 public function testDeleteEntriesListAction()
1158 { 1156 {
1159 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); 1157 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
1160 $em->persist((new Entry($em->getReference(User::class, 1)))->setUrl('http://0.0.0.0/test-entry1')); 1158 $em->persist((new Entry($em->getReference(User::class, $this->getUserId())))->setUrl('http://0.0.0.0/test-entry1'));
1161 1159
1162 $em->flush(); 1160 $em->flush();
1163 $em->clear(); 1161 $em->clear();
@@ -1215,7 +1213,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
1215 public function testRePostEntryAndReUsePublishedAt() 1213 public function testRePostEntryAndReUsePublishedAt()
1216 { 1214 {
1217 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); 1215 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
1218 $entry = new Entry($em->getReference(User::class, 1)); 1216 $entry = new Entry($em->getReference(User::class, $this->getUserId()));
1219 $entry->setTitle('Antoine de Caunes : « Je veux avoir le droit de tâtonner »'); 1217 $entry->setTitle('Antoine de Caunes : « Je veux avoir le droit de tâtonner »');
1220 $entry->setContent('hihi'); 1218 $entry->setContent('hihi');
1221 $entry->setUrl('https://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html'); 1219 $entry->setUrl('https://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html');
diff --git a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php
index 8a188e1c..fd2e113e 100644
--- a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php
+++ b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php
@@ -31,9 +31,9 @@ abstract class WallabagApiTestCase extends WebTestCase
31 $container = $client->getContainer(); 31 $container = $client->getContainer();
32 32
33 /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */ 33 /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
34 $userManager = $container->get('fos_user.user_manager'); 34 $userManager = $container->get('fos_user.user_manager.test');
35 /** @var $loginManager \FOS\UserBundle\Security\LoginManager */ 35 /** @var $loginManager \FOS\UserBundle\Security\LoginManager */
36 $loginManager = $container->get('fos_user.security.login_manager'); 36 $loginManager = $container->get('fos_user.security.login_manager.test');
37 $firewallName = $container->getParameter('fos_user.firewall_name'); 37 $firewallName = $container->getParameter('fos_user.firewall_name');
38 38
39 $this->user = $userManager->findUserBy(['username' => 'admin']); 39 $this->user = $userManager->findUserBy(['username' => 'admin']);
@@ -48,4 +48,23 @@ abstract class WallabagApiTestCase extends WebTestCase
48 48
49 return $client; 49 return $client;
50 } 50 }
51
52 /**
53 * Return the ID for the user admin.
54 * Used because on heavy testing we don't want to re-create the database on each run.
55 * Which means "admin" user won't have id 1 all the time.
56 *
57 * @param string $username
58 *
59 * @return int
60 */
61 protected function getUserId($username = 'admin')
62 {
63 return $this->client
64 ->getContainer()
65 ->get('doctrine.orm.entity_manager')
66 ->getRepository('WallabagUserBundle:User')
67 ->findOneByUserName($username)
68 ->getId();
69 }
51} 70}
diff --git a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php
index bd351b18..d8928451 100644
--- a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php
+++ b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php
@@ -18,6 +18,18 @@ use Wallabag\CoreBundle\Command\InstallCommand;
18 18
19class InstallCommandTest extends WallabagCoreTestCase 19class InstallCommandTest extends WallabagCoreTestCase
20{ 20{
21 public static function setUpBeforeClass()
22 {
23 // disable doctrine-test-bundle
24 StaticDriver::setKeepStaticConnections(false);
25 }
26
27 public static function tearDownAfterClass()
28 {
29 // enable doctrine-test-bundle
30 StaticDriver::setKeepStaticConnections(true);
31 }
32
21 public function setUp() 33 public function setUp()
22 { 34 {
23 parent::setUp(); 35 parent::setUp();
@@ -51,9 +63,6 @@ class InstallCommandTest extends WallabagCoreTestCase
51 parent::setUp(); 63 parent::setUp();
52 } 64 }
53 65
54 // disable doctrine-test-bundle
55 StaticDriver::setKeepStaticConnections(false);
56
57 $this->resetDatabase($this->getClient()); 66 $this->resetDatabase($this->getClient());
58 } 67 }
59 68
@@ -62,6 +71,7 @@ class InstallCommandTest extends WallabagCoreTestCase
62 $databasePath = getenv('TEST_DATABASE_PATH'); 71 $databasePath = getenv('TEST_DATABASE_PATH');
63 // Remove variable environnement 72 // Remove variable environnement
64 putenv('TEST_DATABASE_PATH'); 73 putenv('TEST_DATABASE_PATH');
74
65 if ($databasePath && file_exists($databasePath)) { 75 if ($databasePath && file_exists($databasePath)) {
66 unlink($databasePath); 76 unlink($databasePath);
67 } else { 77 } else {
@@ -71,8 +81,6 @@ class InstallCommandTest extends WallabagCoreTestCase
71 $this->resetDatabase($client); 81 $this->resetDatabase($client);
72 } 82 }
73 83
74 // enable doctrine-test-bundle
75 StaticDriver::setKeepStaticConnections(true);
76 parent::tearDown(); 84 parent::tearDown();
77 } 85 }
78 86
diff --git a/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php b/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php
index b13f6519..c4bd6dac 100644
--- a/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php
+++ b/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php
@@ -26,7 +26,7 @@ class ReloadEntryCommandTest extends WallabagCoreTestCase
26 { 26 {
27 parent::setUp(); 27 parent::setUp();
28 28
29 $userRepository = $this->getClient()->getContainer()->get('wallabag_user.user_repository'); 29 $userRepository = $this->getClient()->getContainer()->get('wallabag_user.user_repository.test');
30 30
31 $user = $userRepository->findOneByUserName('admin'); 31 $user = $userRepository->findOneByUserName('admin');
32 $this->adminEntry = new Entry($user); 32 $this->adminEntry = new Entry($user);
@@ -60,7 +60,7 @@ class ReloadEntryCommandTest extends WallabagCoreTestCase
60 60
61 $reloadedEntries = $this->getClient() 61 $reloadedEntries = $this->getClient()
62 ->getContainer() 62 ->getContainer()
63 ->get('wallabag_core.entry_repository') 63 ->get('wallabag_core.entry_repository.test')
64 ->findById([$this->adminEntry->getId(), $this->bobEntry->getId()]); 64 ->findById([$this->adminEntry->getId(), $this->bobEntry->getId()]);
65 65
66 foreach ($reloadedEntries as $reloadedEntry) { 66 foreach ($reloadedEntries as $reloadedEntry) {
@@ -84,7 +84,7 @@ class ReloadEntryCommandTest extends WallabagCoreTestCase
84 'interactive' => false, 84 'interactive' => false,
85 ]); 85 ]);
86 86
87 $entryRepository = $this->getClient()->getContainer()->get('wallabag_core.entry_repository'); 87 $entryRepository = $this->getClient()->getContainer()->get('wallabag_core.entry_repository.test');
88 88
89 $reloadedAdminEntry = $entryRepository->find($this->adminEntry->getId()); 89 $reloadedAdminEntry = $entryRepository->find($this->adminEntry->getId());
90 $this->assertNotEmpty($reloadedAdminEntry->getContent()); 90 $this->assertNotEmpty($reloadedAdminEntry->getContent());
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
index e07c57dd..cf9f1e97 100644
--- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
@@ -849,7 +849,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
849 $entryArchived->setContent('Youhou'); 849 $entryArchived->setContent('Youhou');
850 $entryArchived->setTitle('Youhou'); 850 $entryArchived->setTitle('Youhou');
851 $entryArchived->addTag($tagArchived); 851 $entryArchived->addTag($tagArchived);
852 $entryArchived->setArchived(true); 852 $entryArchived->updateArchived(true);
853 $em->persist($entryArchived); 853 $em->persist($entryArchived);
854 854
855 $annotationArchived = new Annotation($user); 855 $annotationArchived = new Annotation($user);
@@ -965,4 +965,39 @@ class ConfigControllerTest extends WallabagCoreTestCase
965 965
966 $client->request('GET', '/config/view-mode'); 966 $client->request('GET', '/config/view-mode');
967 } 967 }
968
969 public function testChangeLocaleWithoutReferer()
970 {
971 $client = $this->getClient();
972
973 $client->request('GET', '/locale/de');
974 $client->followRedirect();
975
976 $this->assertSame('de', $client->getRequest()->getLocale());
977 $this->assertSame('de', $client->getContainer()->get('session')->get('_locale'));
978 }
979
980 public function testChangeLocaleWithReferer()
981 {
982 $client = $this->getClient();
983
984 $client->request('GET', '/login');
985 $client->request('GET', '/locale/de');
986 $client->followRedirect();
987
988 $this->assertSame('de', $client->getRequest()->getLocale());
989 $this->assertSame('de', $client->getContainer()->get('session')->get('_locale'));
990 }
991
992 public function testChangeLocaleToBadLocale()
993 {
994 $client = $this->getClient();
995
996 $client->request('GET', '/login');
997 $client->request('GET', '/locale/yuyuyuyu');
998 $client->followRedirect();
999
1000 $this->assertNotSame('yuyuyuyu', $client->getRequest()->getLocale());
1001 $this->assertNotSame('yuyuyuyu', $client->getContainer()->get('session')->get('_locale'));
1002 }
968} 1003}
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 479e0700..006ca330 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -620,7 +620,7 @@ class EntryControllerTest extends WallabagCoreTestCase
620 $content->setMimetype('text/html'); 620 $content->setMimetype('text/html');
621 $content->setTitle('test title entry'); 621 $content->setTitle('test title entry');
622 $content->setContent('This is my content /o/'); 622 $content->setContent('This is my content /o/');
623 $content->setArchived(true); 623 $content->updateArchived(true);
624 $content->setLanguage('fr'); 624 $content->setLanguage('fr');
625 625
626 $em->persist($content); 626 $em->persist($content);
@@ -773,7 +773,7 @@ class EntryControllerTest extends WallabagCoreTestCase
773 773
774 $entry = new Entry($this->getLoggedInUser()); 774 $entry = new Entry($this->getLoggedInUser());
775 $entry->setUrl($this->url); 775 $entry->setUrl($this->url);
776 $entry->setArchived(false); 776 $entry->updateArchived(false);
777 $this->getEntityManager()->persist($entry); 777 $this->getEntityManager()->persist($entry);
778 $this->getEntityManager()->flush(); 778 $this->getEntityManager()->flush();
779 779
@@ -984,8 +984,13 @@ class EntryControllerTest extends WallabagCoreTestCase
984 $client->request('GET', '/share/' . $content->getId()); 984 $client->request('GET', '/share/' . $content->getId());
985 $this->assertSame(302, $client->getResponse()->getStatusCode()); 985 $this->assertSame(302, $client->getResponse()->getStatusCode());
986 986
987 // follow link with uid 987 $shareUrl = $client->getResponse()->getTargetUrl();
988 $crawler = $client->followRedirect(); 988
989 // use a new client to have a fresh empty session (instead of a logged one from the previous client)
990 $client->restart();
991
992 $client->request('GET', $shareUrl);
993
989 $this->assertSame(200, $client->getResponse()->getStatusCode()); 994 $this->assertSame(200, $client->getResponse()->getStatusCode());
990 $this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control')); 995 $this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control'));
991 $this->assertContains('public', $client->getResponse()->headers->get('cache-control')); 996 $this->assertContains('public', $client->getResponse()->headers->get('cache-control'));
@@ -1001,9 +1006,6 @@ class EntryControllerTest extends WallabagCoreTestCase
1001 $client->request('GET', '/share/' . $content->getUid()); 1006 $client->request('GET', '/share/' . $content->getUid());
1002 $this->assertSame(404, $client->getResponse()->getStatusCode()); 1007 $this->assertSame(404, $client->getResponse()->getStatusCode());
1003 1008
1004 $client->request('GET', '/view/' . $content->getId());
1005 $this->assertContains('no-cache', $client->getResponse()->headers->get('cache-control'));
1006
1007 // removing the share 1009 // removing the share
1008 $client->request('GET', '/share/delete/' . $content->getId()); 1010 $client->request('GET', '/share/delete/' . $content->getId());
1009 $this->assertSame(302, $client->getResponse()->getStatusCode()); 1011 $this->assertSame(302, $client->getResponse()->getStatusCode());
@@ -1244,7 +1246,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1244 $entry = new Entry($this->getLoggedInUser()); 1246 $entry = new Entry($this->getLoggedInUser());
1245 $entry->setUrl('http://0.0.0.0/foo/baz/qux'); 1247 $entry->setUrl('http://0.0.0.0/foo/baz/qux');
1246 $entry->setTitle('Le manège'); 1248 $entry->setTitle('Le manège');
1247 $entry->setArchived(true); 1249 $entry->updateArchived(true);
1248 $this->getEntityManager()->persist($entry); 1250 $this->getEntityManager()->persist($entry);
1249 $this->getEntityManager()->flush(); 1251 $this->getEntityManager()->flush();
1250 1252
@@ -1274,7 +1276,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1274 $entry = new Entry($this->getLoggedInUser()); 1276 $entry = new Entry($this->getLoggedInUser());
1275 $entry->setUrl('http://domain/qux'); 1277 $entry->setUrl('http://domain/qux');
1276 $entry->setTitle('Le manège'); 1278 $entry->setTitle('Le manège');
1277 $entry->setArchived(true); 1279 $entry->updateArchived(true);
1278 $this->getEntityManager()->persist($entry); 1280 $this->getEntityManager()->persist($entry);
1279 $this->getEntityManager()->flush(); 1281 $this->getEntityManager()->flush();
1280 1282
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
index 768f4c07..be17dcf5 100644
--- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
@@ -176,4 +176,49 @@ class TagControllerTest extends WallabagCoreTestCase
176 $em->remove($tag); 176 $em->remove($tag);
177 $em->flush(); 177 $em->flush();
178 } 178 }
179
180 public function testRenameTagUsingTheFormInsideTagList()
181 {
182 $this->logInAs('admin');
183 $client = $this->getClient();
184
185 $tag = new Tag();
186 $tag->setLabel($this->tagName);
187 $entry = new Entry($this->getLoggedInUser());
188 $entry->setUrl('http://0.0.0.0/foo');
189 $entry->addTag($tag);
190 $this->getEntityManager()->persist($entry);
191 $this->getEntityManager()->flush();
192 $this->getEntityManager()->clear();
193
194 // We make a first request to set an history and test redirection after tag deletion
195 $crawler = $client->request('GET', '/tag/list');
196 $form = $crawler->filter('#tag-' . $tag->getId() . ' form')->form();
197
198 $data = [
199 'tag[label]' => 'specific label',
200 ];
201
202 $client->submit($form, $data);
203 $this->assertSame(302, $client->getResponse()->getStatusCode());
204
205 $freshEntry = $client->getContainer()
206 ->get('doctrine.orm.entity_manager')
207 ->getRepository('WallabagCoreBundle:Entry')
208 ->find($entry->getId());
209
210 $tags = $freshEntry->getTags()->toArray();
211 foreach ($tags as $key => $item) {
212 $tags[$key] = $item->getLabel();
213 }
214
215 $this->assertFalse(array_search($tag->getLabel(), $tags, true), 'Previous tag is not attach to entry anymore.');
216
217 $newTag = $client->getContainer()
218 ->get('doctrine.orm.entity_manager')
219 ->getRepository('WallabagCoreBundle:Tag')
220 ->findOneByLabel('specific label');
221 $this->assertInstanceOf(Tag::class, $newTag, 'Tag "specific label" exists.');
222 $this->assertTrue($newTag->hasEntry($freshEntry), 'Tag "specific label" is assigned to the entry.');
223 }
179} 224}
diff --git a/tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php b/tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php
index 93edfde8..ff0a9602 100644
--- a/tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php
+++ b/tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php
@@ -56,4 +56,27 @@ class UserLocaleListenerTest extends TestCase
56 56
57 $this->assertNull($session->get('_locale')); 57 $this->assertNull($session->get('_locale'));
58 } 58 }
59
60 public function testWithLanguageFromSession()
61 {
62 $session = new Session(new MockArraySessionStorage());
63 $listener = new UserLocaleListener($session);
64 $session->set('_locale', 'de');
65
66 $user = new User();
67 $user->setEnabled(true);
68
69 $config = new Config($user);
70 $config->setLanguage('fr');
71
72 $user->setConfig($config);
73
74 $userToken = new UsernamePasswordToken($user, '', 'test');
75 $request = Request::create('/');
76 $event = new InteractiveLoginEvent($request, $userToken);
77
78 $listener->onInteractiveLogin($event);
79
80 $this->assertSame('de', $session->get('_locale'));
81 }
59} 82}
diff --git a/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php b/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php
index 6e1163c5..816d22f4 100644
--- a/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php
+++ b/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php
@@ -84,8 +84,8 @@ abstract class WallabagCoreTestCase extends WebTestCase
84 $container = $this->client->getContainer(); 84 $container = $this->client->getContainer();
85 $session = $container->get('session'); 85 $session = $container->get('session');
86 86
87 $userManager = $container->get('fos_user.user_manager'); 87 $userManager = $container->get('fos_user.user_manager.test');
88 $loginManager = $container->get('fos_user.security.login_manager'); 88 $loginManager = $container->get('fos_user.security.login_manager.test');
89 $firewallName = $container->getParameter('fos_user.firewall_name'); 89 $firewallName = $container->getParameter('fos_user.firewall_name');
90 90
91 $user = $userManager->findUserBy(['username' => $username]); 91 $user = $userManager->findUserBy(['username' => $username]);
diff --git a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php
index f95320a4..8e1c528d 100644
--- a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php
+++ b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php
@@ -84,6 +84,8 @@ class ImportCommandTest extends WallabagCoreTestCase
84 84
85 public function testRunImportCommandWithUserId() 85 public function testRunImportCommandWithUserId()
86 { 86 {
87 $this->logInAs('admin');
88
87 $application = new Application($this->getClient()->getKernel()); 89 $application = new Application($this->getClient()->getKernel());
88 $application->add(new ImportCommand()); 90 $application->add(new ImportCommand());
89 91
@@ -92,7 +94,7 @@ class ImportCommandTest extends WallabagCoreTestCase
92 $tester = new CommandTester($command); 94 $tester = new CommandTester($command);
93 $tester->execute([ 95 $tester->execute([
94 'command' => $command->getName(), 96 'command' => $command->getName(),
95 'username' => 1, 97 'username' => $this->getLoggedInUserId(),
96 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.project_dir') . '/tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', 98 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.project_dir') . '/tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json',
97 '--useUserId' => true, 99 '--useUserId' => true,
98 '--importer' => 'v2', 100 '--importer' => 'v2',
diff --git a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
index 2b540fdf..c13bfbea 100644
--- a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
+++ b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
@@ -8,6 +8,8 @@ use PHPUnit\Framework\TestCase;
8use Symfony\Component\EventDispatcher\EventDispatcher; 8use Symfony\Component\EventDispatcher\EventDispatcher;
9use Symfony\Component\HttpFoundation\Request; 9use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\HttpFoundation\Response; 10use Symfony\Component\HttpFoundation\Response;
11use Symfony\Component\HttpFoundation\Session\Session;
12use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
11use Wallabag\CoreBundle\Entity\Config; 13use Wallabag\CoreBundle\Entity\Config;
12use Wallabag\UserBundle\Entity\User; 14use Wallabag\UserBundle\Entity\User;
13use Wallabag\UserBundle\EventListener\CreateConfigListener; 15use Wallabag\UserBundle\EventListener\CreateConfigListener;
@@ -22,6 +24,7 @@ class CreateConfigListenerTest extends TestCase
22 24
23 protected function setUp() 25 protected function setUp()
24 { 26 {
27 $session = new Session(new MockArraySessionStorage());
25 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager') 28 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
26 ->disableOriginalConstructor() 29 ->disableOriginalConstructor()
27 ->getMock(); 30 ->getMock();
@@ -34,7 +37,8 @@ class CreateConfigListenerTest extends TestCase
34 'fr', 37 'fr',
35 1, 38 1,
36 1, 39 1,
37 1 40 1,
41 $session
38 ); 42 );
39 43
40 $this->dispatcher = new EventDispatcher(); 44 $this->dispatcher = new EventDispatcher();