diff options
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller')
3 files changed, 92 insertions, 10 deletions
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 | } |