aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php141
1 files changed, 113 insertions, 28 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index 46b5f460..8b7898ee 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.');
@@ -133,6 +133,27 @@ class EntryRestControllerTest extends WallabagApiTestCase
133 $this->assertSame(1, $content['page']); 133 $this->assertSame(1, $content['page']);
134 $this->assertGreaterThanOrEqual(1, $content['pages']); 134 $this->assertGreaterThanOrEqual(1, $content['pages']);
135 135
136 $this->assertNotNull($content['_embedded']['items'][0]['content']);
137
138 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
139 }
140
141 public function testGetEntriesDetailMetadata()
142 {
143 $this->client->request('GET', '/api/entries?detail=metadata');
144
145 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
146
147 $content = json_decode($this->client->getResponse()->getContent(), true);
148
149 $this->assertGreaterThanOrEqual(1, \count($content));
150 $this->assertNotEmpty($content['_embedded']['items']);
151 $this->assertGreaterThanOrEqual(1, $content['total']);
152 $this->assertSame(1, $content['page']);
153 $this->assertGreaterThanOrEqual(1, $content['pages']);
154
155 $this->assertNull($content['_embedded']['items'][0]['content']);
156
136 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type')); 157 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
137 } 158 }
138 159
@@ -185,7 +206,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
185 $entry = $this->client->getContainer() 206 $entry = $this->client->getContainer()
186 ->get('doctrine.orm.entity_manager') 207 ->get('doctrine.orm.entity_manager')
187 ->getRepository('WallabagCoreBundle:Entry') 208 ->getRepository('WallabagCoreBundle:Entry')
188 ->findOneByUser(1); 209 ->findOneByUser($this->getUserId());
189 210
190 if (!$entry) { 211 if (!$entry) {
191 $this->markTestSkipped('No content found in db.'); 212 $this->markTestSkipped('No content found in db.');
@@ -489,8 +510,9 @@ class EntryRestControllerTest extends WallabagApiTestCase
489 $this->assertSame(0, $content['is_archived']); 510 $this->assertSame(0, $content['is_archived']);
490 $this->assertSame(0, $content['is_starred']); 511 $this->assertSame(0, $content['is_starred']);
491 $this->assertNull($content['starred_at']); 512 $this->assertNull($content['starred_at']);
513 $this->assertNull($content['archived_at']);
492 $this->assertSame('New title for my article', $content['title']); 514 $this->assertSame('New title for my article', $content['title']);
493 $this->assertSame(1, $content['user_id']); 515 $this->assertSame($this->getUserId(), $content['user_id']);
494 $this->assertCount(2, $content['tags']); 516 $this->assertCount(2, $content['tags']);
495 $this->assertNull($content['origin_url']); 517 $this->assertNull($content['origin_url']);
496 $this->assertSame('my content', $content['content']); 518 $this->assertSame('my content', $content['content']);
@@ -505,7 +527,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
505 public function testPostSameEntry() 527 public function testPostSameEntry()
506 { 528 {
507 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); 529 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
508 $entry = new Entry($em->getReference(User::class, 1)); 530 $entry = new Entry($em->getReference(User::class, $this->getUserId()));
509 $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'); 531 $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');
510 $entry->setArchived(true); 532 $entry->setArchived(true);
511 $entry->addTag((new Tag())->setLabel('google')); 533 $entry->addTag((new Tag())->setLabel('google'));
@@ -584,7 +606,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
584 $this->assertSame(1, $content['is_archived']); 606 $this->assertSame(1, $content['is_archived']);
585 $this->assertSame(1, $content['is_starred']); 607 $this->assertSame(1, $content['is_starred']);
586 $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['starred_at']))->getTimestamp()); 608 $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['starred_at']))->getTimestamp());
587 $this->assertSame(1, $content['user_id']); 609 $this->assertGreaterThanOrEqual($now->getTimestamp(), (new \DateTime($content['archived_at']))->getTimestamp());
610 $this->assertSame($this->getUserId(), $content['user_id']);
588 } 611 }
589 612
590 public function testPostArchivedAndStarredEntryWithoutQuotes() 613 public function testPostArchivedAndStarredEntryWithoutQuotes()
@@ -633,7 +656,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
633 $entry = $this->client->getContainer() 656 $entry = $this->client->getContainer()
634 ->get('doctrine.orm.entity_manager') 657 ->get('doctrine.orm.entity_manager')
635 ->getRepository('WallabagCoreBundle:Entry') 658 ->getRepository('WallabagCoreBundle:Entry')
636 ->findOneByUser(1); 659 ->findOneByUser($this->getUserId());
637 660
638 if (!$entry) { 661 if (!$entry) {
639 $this->markTestSkipped('No content found in db.'); 662 $this->markTestSkipped('No content found in db.');
@@ -660,7 +683,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
660 $this->assertSame($entry->getUrl(), $content['url']); 683 $this->assertSame($entry->getUrl(), $content['url']);
661 $this->assertSame('New awesome title', $content['title']); 684 $this->assertSame('New awesome title', $content['title']);
662 $this->assertGreaterThanOrEqual(1, \count($content['tags']), 'We force only one tag'); 685 $this->assertGreaterThanOrEqual(1, \count($content['tags']), 'We force only one tag');
663 $this->assertSame(1, $content['user_id']); 686 $this->assertSame($this->getUserId(), $content['user_id']);
664 $this->assertSame('de_AT', $content['language']); 687 $this->assertSame('de_AT', $content['language']);
665 $this->assertSame('http://preview.io/picture.jpg', $content['preview_picture']); 688 $this->assertSame('http://preview.io/picture.jpg', $content['preview_picture']);
666 $this->assertContains('sponge', $content['published_by']); 689 $this->assertContains('sponge', $content['published_by']);
@@ -675,7 +698,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
675 $entry = $this->client->getContainer() 698 $entry = $this->client->getContainer()
676 ->get('doctrine.orm.entity_manager') 699 ->get('doctrine.orm.entity_manager')
677 ->getRepository('WallabagCoreBundle:Entry') 700 ->getRepository('WallabagCoreBundle:Entry')
678 ->findOneByUser(1); 701 ->findOneByUser($this->getUserId());
679 702
680 if (!$entry) { 703 if (!$entry) {
681 $this->markTestSkipped('No content found in db.'); 704 $this->markTestSkipped('No content found in db.');
@@ -709,7 +732,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
709 $entry = $this->client->getContainer() 732 $entry = $this->client->getContainer()
710 ->get('doctrine.orm.entity_manager') 733 ->get('doctrine.orm.entity_manager')
711 ->getRepository('WallabagCoreBundle:Entry') 734 ->getRepository('WallabagCoreBundle:Entry')
712 ->findOneByUser(1); 735 ->findOneByUser($this->getUserId());
713 736
714 if (!$entry) { 737 if (!$entry) {
715 $this->markTestSkipped('No content found in db.'); 738 $this->markTestSkipped('No content found in db.');
@@ -740,7 +763,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
740 $entry = $this->client->getContainer() 763 $entry = $this->client->getContainer()
741 ->get('doctrine.orm.entity_manager') 764 ->get('doctrine.orm.entity_manager')
742 ->getRepository('WallabagCoreBundle:Entry') 765 ->getRepository('WallabagCoreBundle:Entry')
743 ->findOneByUser(1); 766 ->findOneByUser($this->getUserId());
744 767
745 if (!$entry) { 768 if (!$entry) {
746 $this->markTestSkipped('No content found in db.'); 769 $this->markTestSkipped('No content found in db.');
@@ -772,7 +795,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
772 $entry = $this->client->getContainer() 795 $entry = $this->client->getContainer()
773 ->get('doctrine.orm.entity_manager') 796 ->get('doctrine.orm.entity_manager')
774 ->getRepository('WallabagCoreBundle:Entry') 797 ->getRepository('WallabagCoreBundle:Entry')
775 ->findOneByUser(1); 798 ->findOneByUser($this->getUserId());
776 799
777 if (!$entry) { 800 if (!$entry) {
778 $this->markTestSkipped('No content found in db.'); 801 $this->markTestSkipped('No content found in db.');
@@ -817,7 +840,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
817 $entry = $this->client->getContainer() 840 $entry = $this->client->getContainer()
818 ->get('doctrine.orm.entity_manager') 841 ->get('doctrine.orm.entity_manager')
819 ->getRepository('WallabagCoreBundle:Entry') 842 ->getRepository('WallabagCoreBundle:Entry')
820 ->findOneByUser(1); 843 ->findOneByUser($this->getUserId());
821 844
822 if (!$entry) { 845 if (!$entry) {
823 $this->markTestSkipped('No content found in db.'); 846 $this->markTestSkipped('No content found in db.');
@@ -834,7 +857,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
834 $content = json_decode($this->client->getResponse()->getContent(), true); 857 $content = json_decode($this->client->getResponse()->getContent(), true);
835 858
836 $this->assertArrayHasKey('tags', $content); 859 $this->assertArrayHasKey('tags', $content);
837 $this->assertSame($nbTags + 3, \count($content['tags'])); 860 $this->assertCount($nbTags + 3, $content['tags']);
838 861
839 $entryDB = $this->client->getContainer() 862 $entryDB = $this->client->getContainer()
840 ->get('doctrine.orm.entity_manager') 863 ->get('doctrine.orm.entity_manager')
@@ -874,7 +897,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
874 $content = json_decode($this->client->getResponse()->getContent(), true); 897 $content = json_decode($this->client->getResponse()->getContent(), true);
875 898
876 $this->assertArrayHasKey('tags', $content); 899 $this->assertArrayHasKey('tags', $content);
877 $this->assertSame($nbTags - 1, \count($content['tags'])); 900 $this->assertCount($nbTags - 1, $content['tags']);
878 } 901 }
879 902
880 public function testSaveIsArchivedAfterPost() 903 public function testSaveIsArchivedAfterPost()
@@ -882,7 +905,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
882 $entry = $this->client->getContainer() 905 $entry = $this->client->getContainer()
883 ->get('doctrine.orm.entity_manager') 906 ->get('doctrine.orm.entity_manager')
884 ->getRepository('WallabagCoreBundle:Entry') 907 ->getRepository('WallabagCoreBundle:Entry')
885 ->findOneBy(['user' => 1, 'isArchived' => true]); 908 ->findOneBy(['user' => $this->getUserId(), 'isArchived' => true]);
886 909
887 if (!$entry) { 910 if (!$entry) {
888 $this->markTestSkipped('No content found in db.'); 911 $this->markTestSkipped('No content found in db.');
@@ -904,7 +927,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
904 $entry = $this->client->getContainer() 927 $entry = $this->client->getContainer()
905 ->get('doctrine.orm.entity_manager') 928 ->get('doctrine.orm.entity_manager')
906 ->getRepository('WallabagCoreBundle:Entry') 929 ->getRepository('WallabagCoreBundle:Entry')
907 ->findOneBy(['user' => 1, 'isStarred' => true]); 930 ->findOneBy(['user' => $this->getUserId(), 'isStarred' => true]);
908 931
909 if (!$entry) { 932 if (!$entry) {
910 $this->markTestSkipped('No content found in db.'); 933 $this->markTestSkipped('No content found in db.');
@@ -926,7 +949,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
926 $entry = $this->client->getContainer() 949 $entry = $this->client->getContainer()
927 ->get('doctrine.orm.entity_manager') 950 ->get('doctrine.orm.entity_manager')
928 ->getRepository('WallabagCoreBundle:Entry') 951 ->getRepository('WallabagCoreBundle:Entry')
929 ->findOneBy(['user' => 1, 'isArchived' => true]); 952 ->findOneBy(['user' => $this->getUserId(), 'isArchived' => true]);
930 953
931 if (!$entry) { 954 if (!$entry) {
932 $this->markTestSkipped('No content found in db.'); 955 $this->markTestSkipped('No content found in db.');
@@ -952,7 +975,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
952 $entry = $this->client->getContainer() 975 $entry = $this->client->getContainer()
953 ->get('doctrine.orm.entity_manager') 976 ->get('doctrine.orm.entity_manager')
954 ->getRepository('WallabagCoreBundle:Entry') 977 ->getRepository('WallabagCoreBundle:Entry')
955 ->findOneBy(['user' => 1, 'isStarred' => true]); 978 ->findOneBy(['user' => $this->getUserId(), 'isStarred' => true]);
956 979
957 if (!$entry) { 980 if (!$entry) {
958 $this->markTestSkipped('No content found in db.'); 981 $this->markTestSkipped('No content found in db.');
@@ -971,6 +994,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
971 994
972 public function dataForEntriesExistWithUrl() 995 public function dataForEntriesExistWithUrl()
973 { 996 {
997 $url = hash('sha1', 'http://0.0.0.0/entry2');
998
974 return [ 999 return [
975 'with_id' => [ 1000 'with_id' => [
976 'url' => '/api/entries/exists?url=http://0.0.0.0/entry2&return_id=1', 1001 'url' => '/api/entries/exists?url=http://0.0.0.0/entry2&return_id=1',
@@ -980,6 +1005,14 @@ class EntryRestControllerTest extends WallabagApiTestCase
980 'url' => '/api/entries/exists?url=http://0.0.0.0/entry2', 1005 'url' => '/api/entries/exists?url=http://0.0.0.0/entry2',
981 'expectedValue' => true, 1006 'expectedValue' => true,
982 ], 1007 ],
1008 'hashed_url_with_id' => [
1009 'url' => '/api/entries/exists?hashed_url=' . $url . '&return_id=1',
1010 'expectedValue' => 2,
1011 ],
1012 'hashed_url_without_id' => [
1013 'url' => '/api/entries/exists?hashed_url=' . $url . '',
1014 'expectedValue' => true,
1015 ],
983 ]; 1016 ];
984 } 1017 }
985 1018
@@ -1001,6 +1034,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
1001 { 1034 {
1002 $url1 = 'http://0.0.0.0/entry2'; 1035 $url1 = 'http://0.0.0.0/entry2';
1003 $url2 = 'http://0.0.0.0/entry10'; 1036 $url2 = 'http://0.0.0.0/entry10';
1037
1004 $this->client->request('GET', '/api/entries/exists?urls[]=' . $url1 . '&urls[]=' . $url2 . '&return_id=1'); 1038 $this->client->request('GET', '/api/entries/exists?urls[]=' . $url1 . '&urls[]=' . $url2 . '&return_id=1');
1005 1039
1006 $this->assertSame(200, $this->client->getResponse()->getStatusCode()); 1040 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
@@ -1009,7 +1043,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
1009 1043
1010 $this->assertArrayHasKey($url1, $content); 1044 $this->assertArrayHasKey($url1, $content);
1011 $this->assertArrayHasKey($url2, $content); 1045 $this->assertArrayHasKey($url2, $content);
1012 $this->assertSame(2, $content[$url1]); 1046 // it returns a database id, we don't know it, so we only check it's greater than the lowest possible value
1047 $this->assertGreaterThan(1, $content[$url1]);
1013 $this->assertNull($content[$url2]); 1048 $this->assertNull($content[$url2]);
1014 } 1049 }
1015 1050
@@ -1029,6 +1064,38 @@ class EntryRestControllerTest extends WallabagApiTestCase
1029 $this->assertFalse($content[$url2]); 1064 $this->assertFalse($content[$url2]);
1030 } 1065 }
1031 1066
1067 public function testGetEntriesExistsWithManyUrlsHashed()
1068 {
1069 $url1 = 'http://0.0.0.0/entry2';
1070 $url2 = 'http://0.0.0.0/entry10';
1071 $this->client->request('GET', '/api/entries/exists?hashed_urls[]=' . hash('sha1', $url1) . '&hashed_urls[]=' . hash('sha1', $url2) . '&return_id=1');
1072
1073 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
1074
1075 $content = json_decode($this->client->getResponse()->getContent(), true);
1076
1077 $this->assertArrayHasKey(hash('sha1', $url1), $content);
1078 $this->assertArrayHasKey(hash('sha1', $url2), $content);
1079 $this->assertSame(2, $content[hash('sha1', $url1)]);
1080 $this->assertNull($content[hash('sha1', $url2)]);
1081 }
1082
1083 public function testGetEntriesExistsWithManyUrlsHashedReturnBool()
1084 {
1085 $url1 = 'http://0.0.0.0/entry2';
1086 $url2 = 'http://0.0.0.0/entry10';
1087 $this->client->request('GET', '/api/entries/exists?hashed_urls[]=' . hash('sha1', $url1) . '&hashed_urls[]=' . hash('sha1', $url2));
1088
1089 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
1090
1091 $content = json_decode($this->client->getResponse()->getContent(), true);
1092
1093 $this->assertArrayHasKey(hash('sha1', $url1), $content);
1094 $this->assertArrayHasKey(hash('sha1', $url2), $content);
1095 $this->assertTrue($content[hash('sha1', $url1)]);
1096 $this->assertFalse($content[hash('sha1', $url2)]);
1097 }
1098
1032 public function testGetEntriesExistsWhichDoesNotExists() 1099 public function testGetEntriesExistsWhichDoesNotExists()
1033 { 1100 {
1034 $this->client->request('GET', '/api/entries/exists?url=http://google.com/entry2'); 1101 $this->client->request('GET', '/api/entries/exists?url=http://google.com/entry2');
@@ -1040,6 +1107,17 @@ class EntryRestControllerTest extends WallabagApiTestCase
1040 $this->assertFalse($content['exists']); 1107 $this->assertFalse($content['exists']);
1041 } 1108 }
1042 1109
1110 public function testGetEntriesExistsWhichDoesNotExistsWithHashedUrl()
1111 {
1112 $this->client->request('GET', '/api/entries/exists?hashed_url=' . hash('sha1', 'http://google.com/entry2'));
1113
1114 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
1115
1116 $content = json_decode($this->client->getResponse()->getContent(), true);
1117
1118 $this->assertFalse($content['exists']);
1119 }
1120
1043 public function testGetEntriesExistsWithNoUrl() 1121 public function testGetEntriesExistsWithNoUrl()
1044 { 1122 {
1045 $this->client->request('GET', '/api/entries/exists?url='); 1123 $this->client->request('GET', '/api/entries/exists?url=');
@@ -1047,11 +1125,18 @@ class EntryRestControllerTest extends WallabagApiTestCase
1047 $this->assertSame(403, $this->client->getResponse()->getStatusCode()); 1125 $this->assertSame(403, $this->client->getResponse()->getStatusCode());
1048 } 1126 }
1049 1127
1128 public function testGetEntriesExistsWithNoHashedUrl()
1129 {
1130 $this->client->request('GET', '/api/entries/exists?hashed_url=');
1131
1132 $this->assertSame(403, $this->client->getResponse()->getStatusCode());
1133 }
1134
1050 public function testReloadEntryErrorWhileFetching() 1135 public function testReloadEntryErrorWhileFetching()
1051 { 1136 {
1052 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') 1137 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
1053 ->getRepository('WallabagCoreBundle:Entry') 1138 ->getRepository('WallabagCoreBundle:Entry')
1054 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); 1139 ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getUserId());
1055 1140
1056 if (!$entry) { 1141 if (!$entry) {
1057 $this->markTestSkipped('No content found in db.'); 1142 $this->markTestSkipped('No content found in db.');
@@ -1087,7 +1172,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
1087 { 1172 {
1088 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') 1173 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
1089 ->getRepository('WallabagCoreBundle:Entry') 1174 ->getRepository('WallabagCoreBundle:Entry')
1090 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); 1175 ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getUserId());
1091 1176
1092 $tags = $entry->getTags(); 1177 $tags = $entry->getTags();
1093 1178
@@ -1111,7 +1196,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
1111 1196
1112 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') 1197 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
1113 ->getRepository('WallabagCoreBundle:Entry') 1198 ->getRepository('WallabagCoreBundle:Entry')
1114 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); 1199 ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getUserId());
1115 1200
1116 $tags = $entry->getTags(); 1201 $tags = $entry->getTags();
1117 $this->assertCount(4, $tags); 1202 $this->assertCount(4, $tags);
@@ -1131,7 +1216,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
1131 public function testDeleteEntriesTagsListAction() 1216 public function testDeleteEntriesTagsListAction()
1132 { 1217 {
1133 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); 1218 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
1134 $entry = new Entry($em->getReference(User::class, 1)); 1219 $entry = new Entry($em->getReference(User::class, $this->getUserId()));
1135 $entry->setUrl('http://0.0.0.0/test-entry'); 1220 $entry->setUrl('http://0.0.0.0/test-entry');
1136 $entry->addTag((new Tag())->setLabel('foo-tag')); 1221 $entry->addTag((new Tag())->setLabel('foo-tag'));
1137 $entry->addTag((new Tag())->setLabel('bar-tag')); 1222 $entry->addTag((new Tag())->setLabel('bar-tag'));
@@ -1199,7 +1284,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
1199 public function testDeleteEntriesListAction() 1284 public function testDeleteEntriesListAction()
1200 { 1285 {
1201 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); 1286 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
1202 $em->persist((new Entry($em->getReference(User::class, 1)))->setUrl('http://0.0.0.0/test-entry1')); 1287 $em->persist((new Entry($em->getReference(User::class, $this->getUserId())))->setUrl('http://0.0.0.0/test-entry1'));
1203 1288
1204 $em->flush(); 1289 $em->flush();
1205 $em->clear(); 1290 $em->clear();
@@ -1257,7 +1342,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
1257 public function testRePostEntryAndReUsePublishedAt() 1342 public function testRePostEntryAndReUsePublishedAt()
1258 { 1343 {
1259 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); 1344 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
1260 $entry = new Entry($em->getReference(User::class, 1)); 1345 $entry = new Entry($em->getReference(User::class, $this->getUserId()));
1261 $entry->setTitle('Antoine de Caunes : « Je veux avoir le droit de tâtonner »'); 1346 $entry->setTitle('Antoine de Caunes : « Je veux avoir le droit de tâtonner »');
1262 $entry->setContent('hihi'); 1347 $entry->setContent('hihi');
1263 $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'); 1348 $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');