aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php91
1 files changed, 89 insertions, 2 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
index beb0598a..5bc815ee 100644
--- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
@@ -67,8 +67,17 @@ class ConfigControllerTest extends WallabagCoreTestCase
67 public function testChangeReadingSpeed() 67 public function testChangeReadingSpeed()
68 { 68 {
69 $this->logInAs('admin'); 69 $this->logInAs('admin');
70 $this->useTheme('baggy');
70 $client = $this->getClient(); 71 $client = $this->getClient();
71 72
73 $entry = new Entry($this->getLoggedInUser());
74 $entry->setUrl('http://0.0.0.0/test-entry1')
75 ->setReadingTime(22);
76 $this->getEntityManager()->persist($entry);
77
78 $this->getEntityManager()->flush();
79 $this->getEntityManager()->clear();
80
72 $crawler = $client->request('GET', '/unread/list'); 81 $crawler = $client->request('GET', '/unread/list');
73 $form = $crawler->filter('button[id=submit-filter]')->form(); 82 $form = $crawler->filter('button[id=submit-filter]')->form();
74 $dataFilters = [ 83 $dataFilters = [
@@ -409,6 +418,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
409 public function testTaggingRuleCreation() 418 public function testTaggingRuleCreation()
410 { 419 {
411 $this->logInAs('admin'); 420 $this->logInAs('admin');
421 $this->useTheme('baggy');
412 $client = $this->getClient(); 422 $client = $this->getClient();
413 423
414 $crawler = $client->request('GET', '/config'); 424 $crawler = $client->request('GET', '/config');
@@ -798,11 +808,87 @@ class ConfigControllerTest extends WallabagCoreTestCase
798 808
799 $entryReset = $em 809 $entryReset = $em
800 ->getRepository('WallabagCoreBundle:Entry') 810 ->getRepository('WallabagCoreBundle:Entry')
801 ->countAllEntriesByUsername($user->getId()); 811 ->countAllEntriesByUser($user->getId());
802 812
803 $this->assertEquals(0, $entryReset, 'Entries were reset'); 813 $this->assertEquals(0, $entryReset, 'Entries were reset');
804 } 814 }
805 815
816 public function testResetArchivedEntries()
817 {
818 $this->logInAs('empty');
819 $client = $this->getClient();
820
821 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
822
823 $user = static::$kernel->getContainer()->get('security.token_storage')->getToken()->getUser();
824
825 $tag = new Tag();
826 $tag->setLabel('super');
827 $em->persist($tag);
828
829 $entry = new Entry($user);
830 $entry->setUrl('http://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html');
831 $entry->setContent('Youhou');
832 $entry->setTitle('Youhou');
833 $entry->addTag($tag);
834 $em->persist($entry);
835
836 $annotation = new Annotation($user);
837 $annotation->setText('annotated');
838 $annotation->setQuote('annotated');
839 $annotation->setRanges([]);
840 $annotation->setEntry($entry);
841 $em->persist($annotation);
842
843 $tagArchived = new Tag();
844 $tagArchived->setLabel('super');
845 $em->persist($tagArchived);
846
847 $entryArchived = new Entry($user);
848 $entryArchived->setUrl('http://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html');
849 $entryArchived->setContent('Youhou');
850 $entryArchived->setTitle('Youhou');
851 $entryArchived->addTag($tagArchived);
852 $entryArchived->setArchived(true);
853 $em->persist($entryArchived);
854
855 $annotationArchived = new Annotation($user);
856 $annotationArchived->setText('annotated');
857 $annotationArchived->setQuote('annotated');
858 $annotationArchived->setRanges([]);
859 $annotationArchived->setEntry($entryArchived);
860 $em->persist($annotationArchived);
861
862 $em->flush();
863
864 $crawler = $client->request('GET', '/config#set3');
865
866 $this->assertEquals(200, $client->getResponse()->getStatusCode());
867
868 $crawler = $client->click($crawler->selectLink('config.reset.archived')->link());
869
870 $this->assertEquals(302, $client->getResponse()->getStatusCode());
871 $this->assertContains('flashes.config.notice.archived_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
872
873 $entryReset = $em
874 ->getRepository('WallabagCoreBundle:Entry')
875 ->countAllEntriesByUser($user->getId());
876
877 $this->assertEquals(1, $entryReset, 'Entries were reset');
878
879 $tagReset = $em
880 ->getRepository('WallabagCoreBundle:Tag')
881 ->countAllTags($user->getId());
882
883 $this->assertEquals(1, $tagReset, 'Tags were reset');
884
885 $annotationsReset = $em
886 ->getRepository('WallabagAnnotationBundle:Annotation')
887 ->findAnnotationsByPageId($annotationArchived->getId(), $user->getId());
888
889 $this->assertEmpty($annotationsReset, 'Annotations were reset');
890 }
891
806 public function testResetEntriesCascade() 892 public function testResetEntriesCascade()
807 { 893 {
808 $this->logInAs('empty'); 894 $this->logInAs('empty');
@@ -843,7 +929,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
843 929
844 $entryReset = $em 930 $entryReset = $em
845 ->getRepository('WallabagCoreBundle:Entry') 931 ->getRepository('WallabagCoreBundle:Entry')
846 ->countAllEntriesByUsername($user->getId()); 932 ->countAllEntriesByUser($user->getId());
847 933
848 $this->assertEquals(0, $entryReset, 'Entries were reset'); 934 $this->assertEquals(0, $entryReset, 'Entries were reset');
849 935
@@ -863,6 +949,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
863 public function testSwitchViewMode() 949 public function testSwitchViewMode()
864 { 950 {
865 $this->logInAs('admin'); 951 $this->logInAs('admin');
952 $this->useTheme('baggy');
866 $client = $this->getClient(); 953 $client = $this->getClient();
867 954
868 $client->request('GET', '/unread/list'); 955 $client->request('GET', '/unread/list');