diff options
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller')
6 files changed, 227 insertions, 27 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index e07c57dd..1090a686 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php | |||
@@ -1,6 +1,6 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace tests\Wallabag\CoreBundle\Controller; | 3 | namespace Tests\Wallabag\CoreBundle\Controller; |
4 | 4 | ||
5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | 5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; |
6 | use Wallabag\AnnotationBundle\Entity\Annotation; | 6 | use Wallabag\AnnotationBundle\Entity\Annotation; |
@@ -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,120 @@ 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 | } | ||
1003 | |||
1004 | public function testUserEnable2faEmail() | ||
1005 | { | ||
1006 | $this->logInAs('admin'); | ||
1007 | $client = $this->getClient(); | ||
1008 | |||
1009 | $crawler = $client->request('GET', '/config/otp/email'); | ||
1010 | |||
1011 | $this->assertSame(302, $client->getResponse()->getStatusCode()); | ||
1012 | |||
1013 | $crawler = $client->followRedirect(); | ||
1014 | |||
1015 | $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text'])); | ||
1016 | $this->assertContains('flashes.config.notice.otp_enabled', $alert[0]); | ||
1017 | |||
1018 | // restore user | ||
1019 | $em = $this->getEntityManager(); | ||
1020 | $user = $em | ||
1021 | ->getRepository('WallabagUserBundle:User') | ||
1022 | ->findOneByUsername('admin'); | ||
1023 | |||
1024 | $this->assertTrue($user->isEmailTwoFactor()); | ||
1025 | |||
1026 | $user->setEmailTwoFactor(false); | ||
1027 | $em->persist($user); | ||
1028 | $em->flush(); | ||
1029 | } | ||
1030 | |||
1031 | public function testUserEnable2faGoogle() | ||
1032 | { | ||
1033 | $this->logInAs('admin'); | ||
1034 | $client = $this->getClient(); | ||
1035 | |||
1036 | $crawler = $client->request('GET', '/config/otp/app'); | ||
1037 | |||
1038 | $this->assertSame(200, $client->getResponse()->getStatusCode()); | ||
1039 | |||
1040 | // restore user | ||
1041 | $em = $this->getEntityManager(); | ||
1042 | $user = $em | ||
1043 | ->getRepository('WallabagUserBundle:User') | ||
1044 | ->findOneByUsername('admin'); | ||
1045 | |||
1046 | $this->assertTrue($user->isGoogleTwoFactor()); | ||
1047 | $this->assertGreaterThan(0, $user->getBackupCodes()); | ||
1048 | |||
1049 | $user->setGoogleAuthenticatorSecret(false); | ||
1050 | $user->setBackupCodes(null); | ||
1051 | $em->persist($user); | ||
1052 | $em->flush(); | ||
1053 | } | ||
1054 | |||
1055 | public function testUserEnable2faGoogleCancel() | ||
1056 | { | ||
1057 | $this->logInAs('admin'); | ||
1058 | $client = $this->getClient(); | ||
1059 | |||
1060 | $crawler = $client->request('GET', '/config/otp/app'); | ||
1061 | |||
1062 | $this->assertSame(200, $client->getResponse()->getStatusCode()); | ||
1063 | |||
1064 | // restore user | ||
1065 | $em = $this->getEntityManager(); | ||
1066 | $user = $em | ||
1067 | ->getRepository('WallabagUserBundle:User') | ||
1068 | ->findOneByUsername('admin'); | ||
1069 | |||
1070 | $this->assertTrue($user->isGoogleTwoFactor()); | ||
1071 | $this->assertGreaterThan(0, $user->getBackupCodes()); | ||
1072 | |||
1073 | $crawler = $client->request('GET', '/config/otp/app/cancel'); | ||
1074 | |||
1075 | $this->assertSame(302, $client->getResponse()->getStatusCode()); | ||
1076 | |||
1077 | $user = $em | ||
1078 | ->getRepository('WallabagUserBundle:User') | ||
1079 | ->findOneByUsername('admin'); | ||
1080 | |||
1081 | $this->assertFalse($user->isGoogleTwoFactor()); | ||
1082 | $this->assertEmpty($user->getBackupCodes()); | ||
1083 | } | ||
968 | } | 1084 | } |
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 479e0700..28291b5a 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -522,9 +522,12 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
522 | 522 | ||
523 | $crawler = $client->followRedirect(); | 523 | $crawler = $client->followRedirect(); |
524 | 524 | ||
525 | $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); | 525 | $title = $crawler->filter('div[id=article] h1')->extract(['_text']); |
526 | $this->assertGreaterThan(1, $title); | ||
526 | $this->assertContains('My updated title hehe :)', $title[0]); | 527 | $this->assertContains('My updated title hehe :)', $title[0]); |
527 | $this->assertSame(1, \count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']))); | 528 | |
529 | $stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']); | ||
530 | $this->assertCount(1, $stats); | ||
528 | $this->assertNotContains('example.io', trim($stats[0])); | 531 | $this->assertNotContains('example.io', trim($stats[0])); |
529 | } | 532 | } |
530 | 533 | ||
@@ -620,7 +623,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
620 | $content->setMimetype('text/html'); | 623 | $content->setMimetype('text/html'); |
621 | $content->setTitle('test title entry'); | 624 | $content->setTitle('test title entry'); |
622 | $content->setContent('This is my content /o/'); | 625 | $content->setContent('This is my content /o/'); |
623 | $content->setArchived(true); | 626 | $content->updateArchived(true); |
624 | $content->setLanguage('fr'); | 627 | $content->setLanguage('fr'); |
625 | 628 | ||
626 | $em->persist($content); | 629 | $em->persist($content); |
@@ -773,7 +776,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
773 | 776 | ||
774 | $entry = new Entry($this->getLoggedInUser()); | 777 | $entry = new Entry($this->getLoggedInUser()); |
775 | $entry->setUrl($this->url); | 778 | $entry->setUrl($this->url); |
776 | $entry->setArchived(false); | 779 | $entry->updateArchived(false); |
777 | $this->getEntityManager()->persist($entry); | 780 | $this->getEntityManager()->persist($entry); |
778 | $this->getEntityManager()->flush(); | 781 | $this->getEntityManager()->flush(); |
779 | 782 | ||
@@ -984,8 +987,13 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
984 | $client->request('GET', '/share/' . $content->getId()); | 987 | $client->request('GET', '/share/' . $content->getId()); |
985 | $this->assertSame(302, $client->getResponse()->getStatusCode()); | 988 | $this->assertSame(302, $client->getResponse()->getStatusCode()); |
986 | 989 | ||
987 | // follow link with uid | 990 | $shareUrl = $client->getResponse()->getTargetUrl(); |
988 | $crawler = $client->followRedirect(); | 991 | |
992 | // use a new client to have a fresh empty session (instead of a logged one from the previous client) | ||
993 | $client->restart(); | ||
994 | |||
995 | $client->request('GET', $shareUrl); | ||
996 | |||
989 | $this->assertSame(200, $client->getResponse()->getStatusCode()); | 997 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
990 | $this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control')); | 998 | $this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control')); |
991 | $this->assertContains('public', $client->getResponse()->headers->get('cache-control')); | 999 | $this->assertContains('public', $client->getResponse()->headers->get('cache-control')); |
@@ -1001,9 +1009,6 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1001 | $client->request('GET', '/share/' . $content->getUid()); | 1009 | $client->request('GET', '/share/' . $content->getUid()); |
1002 | $this->assertSame(404, $client->getResponse()->getStatusCode()); | 1010 | $this->assertSame(404, $client->getResponse()->getStatusCode()); |
1003 | 1011 | ||
1004 | $client->request('GET', '/view/' . $content->getId()); | ||
1005 | $this->assertContains('no-cache', $client->getResponse()->headers->get('cache-control')); | ||
1006 | |||
1007 | // removing the share | 1012 | // removing the share |
1008 | $client->request('GET', '/share/delete/' . $content->getId()); | 1013 | $client->request('GET', '/share/delete/' . $content->getId()); |
1009 | $this->assertSame(302, $client->getResponse()->getStatusCode()); | 1014 | $this->assertSame(302, $client->getResponse()->getStatusCode()); |
@@ -1244,7 +1249,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1244 | $entry = new Entry($this->getLoggedInUser()); | 1249 | $entry = new Entry($this->getLoggedInUser()); |
1245 | $entry->setUrl('http://0.0.0.0/foo/baz/qux'); | 1250 | $entry->setUrl('http://0.0.0.0/foo/baz/qux'); |
1246 | $entry->setTitle('Le manège'); | 1251 | $entry->setTitle('Le manège'); |
1247 | $entry->setArchived(true); | 1252 | $entry->updateArchived(true); |
1248 | $this->getEntityManager()->persist($entry); | 1253 | $this->getEntityManager()->persist($entry); |
1249 | $this->getEntityManager()->flush(); | 1254 | $this->getEntityManager()->flush(); |
1250 | 1255 | ||
@@ -1274,7 +1279,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1274 | $entry = new Entry($this->getLoggedInUser()); | 1279 | $entry = new Entry($this->getLoggedInUser()); |
1275 | $entry->setUrl('http://domain/qux'); | 1280 | $entry->setUrl('http://domain/qux'); |
1276 | $entry->setTitle('Le manège'); | 1281 | $entry->setTitle('Le manège'); |
1277 | $entry->setArchived(true); | 1282 | $entry->updateArchived(true); |
1278 | $this->getEntityManager()->persist($entry); | 1283 | $this->getEntityManager()->persist($entry); |
1279 | $this->getEntityManager()->flush(); | 1284 | $this->getEntityManager()->flush(); |
1280 | 1285 | ||
@@ -1325,10 +1330,6 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1325 | 'http://www.hao123.com/shequ?__noscript__-=1', | 1330 | 'http://www.hao123.com/shequ?__noscript__-=1', |
1326 | 'zh_CN', | 1331 | 'zh_CN', |
1327 | ], | 1332 | ], |
1328 | 'ru' => [ | ||
1329 | 'https://www.kp.ru/daily/26879.7/3921982/', | ||
1330 | 'ru', | ||
1331 | ], | ||
1332 | 'pt_BR' => [ | 1333 | 'pt_BR' => [ |
1333 | 'https://politica.estadao.com.br/noticias/eleicoes,campanha-catatonica,70002491983', | 1334 | 'https://politica.estadao.com.br/noticias/eleicoes,campanha-catatonica,70002491983', |
1334 | 'pt_BR', | 1335 | 'pt_BR', |
@@ -1494,4 +1495,30 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1494 | 1495 | ||
1495 | $this->assertSame(sprintf('/remove-tag/%s/%s', $entry->getId(), $tag->getId()), $link); | 1496 | $this->assertSame(sprintf('/remove-tag/%s/%s', $entry->getId(), $tag->getId()), $link); |
1496 | } | 1497 | } |
1498 | |||
1499 | public function testRandom() | ||
1500 | { | ||
1501 | $this->logInAs('admin'); | ||
1502 | $client = $this->getClient(); | ||
1503 | |||
1504 | $client->request('GET', '/unread/random'); | ||
1505 | $this->assertSame(302, $client->getResponse()->getStatusCode()); | ||
1506 | $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'Unread random'); | ||
1507 | |||
1508 | $client->request('GET', '/starred/random'); | ||
1509 | $this->assertSame(302, $client->getResponse()->getStatusCode()); | ||
1510 | $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'Starred random'); | ||
1511 | |||
1512 | $client->request('GET', '/archive/random'); | ||
1513 | $this->assertSame(302, $client->getResponse()->getStatusCode()); | ||
1514 | $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'Archive random'); | ||
1515 | |||
1516 | $client->request('GET', '/untagged/random'); | ||
1517 | $this->assertSame(302, $client->getResponse()->getStatusCode()); | ||
1518 | $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'Untagged random'); | ||
1519 | |||
1520 | $client->request('GET', '/all/random'); | ||
1521 | $this->assertSame(302, $client->getResponse()->getStatusCode()); | ||
1522 | $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'All random'); | ||
1523 | } | ||
1497 | } | 1524 | } |
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php index 0c3d4c83..d7ce7c45 100644 --- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | |||
@@ -180,7 +180,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
180 | 180 | ||
181 | $this->assertGreaterThan(1, $csv); | 181 | $this->assertGreaterThan(1, $csv); |
182 | // +1 for title line | 182 | // +1 for title line |
183 | $this->assertSame(\count($contentInDB) + 1, \count($csv)); | 183 | $this->assertCount(\count($contentInDB) + 1, $csv); |
184 | $this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); | 184 | $this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); |
185 | $this->assertContains($contentInDB[0]['title'], $csv[1]); | 185 | $this->assertContains($contentInDB[0]['title'], $csv[1]); |
186 | $this->assertContains($contentInDB[0]['url'], $csv[1]); | 186 | $this->assertContains($contentInDB[0]['url'], $csv[1]); |
diff --git a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php index 2af6e14f..afa90621 100644 --- a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php | |||
@@ -11,7 +11,7 @@ class RssControllerTest extends WallabagCoreTestCase | |||
11 | $doc = new \DOMDocument(); | 11 | $doc = new \DOMDocument(); |
12 | $doc->loadXML($xml); | 12 | $doc->loadXML($xml); |
13 | 13 | ||
14 | $xpath = new \DOMXpath($doc); | 14 | $xpath = new \DOMXPath($doc); |
15 | 15 | ||
16 | if (null === $nb) { | 16 | if (null === $nb) { |
17 | $this->assertGreaterThan(0, $xpath->query('//item')->length); | 17 | $this->assertGreaterThan(0, $xpath->query('//item')->length); |
diff --git a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php index 395208a2..b03c7550 100644 --- a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php | |||
@@ -26,7 +26,7 @@ class SecurityControllerTest extends WallabagCoreTestCase | |||
26 | $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(['_text'])[0]); | 26 | $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(['_text'])[0]); |
27 | } | 27 | } |
28 | 28 | ||
29 | public function testLoginWith2Factor() | 29 | public function testLoginWith2FactorEmail() |
30 | { | 30 | { |
31 | $client = $this->getClient(); | 31 | $client = $this->getClient(); |
32 | 32 | ||
@@ -42,7 +42,7 @@ class SecurityControllerTest extends WallabagCoreTestCase | |||
42 | $user = $em | 42 | $user = $em |
43 | ->getRepository('WallabagUserBundle:User') | 43 | ->getRepository('WallabagUserBundle:User') |
44 | ->findOneByUsername('admin'); | 44 | ->findOneByUsername('admin'); |
45 | $user->setTwoFactorAuthentication(true); | 45 | $user->setEmailTwoFactor(true); |
46 | $em->persist($user); | 46 | $em->persist($user); |
47 | $em->flush(); | 47 | $em->flush(); |
48 | 48 | ||
@@ -54,12 +54,12 @@ class SecurityControllerTest extends WallabagCoreTestCase | |||
54 | $user = $em | 54 | $user = $em |
55 | ->getRepository('WallabagUserBundle:User') | 55 | ->getRepository('WallabagUserBundle:User') |
56 | ->findOneByUsername('admin'); | 56 | ->findOneByUsername('admin'); |
57 | $user->setTwoFactorAuthentication(false); | 57 | $user->setEmailTwoFactor(false); |
58 | $em->persist($user); | 58 | $em->persist($user); |
59 | $em->flush(); | 59 | $em->flush(); |
60 | } | 60 | } |
61 | 61 | ||
62 | public function testTrustedComputer() | 62 | public function testLoginWith2FactorGoogle() |
63 | { | 63 | { |
64 | $client = $this->getClient(); | 64 | $client = $this->getClient(); |
65 | 65 | ||
@@ -69,15 +69,27 @@ class SecurityControllerTest extends WallabagCoreTestCase | |||
69 | return; | 69 | return; |
70 | } | 70 | } |
71 | 71 | ||
72 | $client->followRedirects(); | ||
73 | |||
72 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | 74 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); |
73 | $user = $em | 75 | $user = $em |
74 | ->getRepository('WallabagUserBundle:User') | 76 | ->getRepository('WallabagUserBundle:User') |
75 | ->findOneByUsername('admin'); | 77 | ->findOneByUsername('admin'); |
78 | $user->setGoogleAuthenticatorSecret('26LDIHYGHNELOQEM'); | ||
79 | $em->persist($user); | ||
80 | $em->flush(); | ||
81 | |||
82 | $this->logInAsUsingHttp('admin'); | ||
83 | $crawler = $client->request('GET', '/config'); | ||
84 | $this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(['_text'])[0]); | ||
76 | 85 | ||
77 | $date = new \DateTime(); | 86 | // restore user |
78 | $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M'))); | 87 | $user = $em |
79 | $this->assertTrue($user->isTrustedComputer('ABCDEF')); | 88 | ->getRepository('WallabagUserBundle:User') |
80 | $this->assertFalse($user->isTrustedComputer('FEDCBA')); | 89 | ->findOneByUsername('admin'); |
90 | $user->setGoogleAuthenticatorSecret(null); | ||
91 | $em->persist($user); | ||
92 | $em->flush(); | ||
81 | } | 93 | } |
82 | 94 | ||
83 | public function testEnabledRegistration() | 95 | public function testEnabledRegistration() |
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 | } |