aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2017-03-31 17:28:54 +0200
committerGitHub <noreply@github.com>2017-03-31 17:28:54 +0200
commit19122cf66037f86375072ffa60b6a43b54f02f99 (patch)
tree62dc0812bc74e08f6fec9962bb62748e95e08aae /tests
parentfa884b30ba0f8cb4231bd37fff23ef2f41ae6cfa (diff)
parent13a592a1288d7deb49211838368583c0109a5fbd (diff)
downloadwallabag-19122cf66037f86375072ffa60b6a43b54f02f99.tar.gz
wallabag-19122cf66037f86375072ffa60b6a43b54f02f99.tar.zst
wallabag-19122cf66037f86375072ffa60b6a43b54f02f99.zip
Merge pull request #3020 from wallabag/add-remove-archived-entries
Allow to remove all archived entries
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php76
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
index 8f2ca1cb..35888f16 100644
--- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
@@ -803,6 +803,82 @@ class ConfigControllerTest extends WallabagCoreTestCase
803 $this->assertEquals(0, $entryReset, 'Entries were reset'); 803 $this->assertEquals(0, $entryReset, 'Entries were reset');
804 } 804 }
805 805
806 public function testResetArchivedEntries()
807 {
808 $this->logInAs('empty');
809 $client = $this->getClient();
810
811 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
812
813 $user = static::$kernel->getContainer()->get('security.token_storage')->getToken()->getUser();
814
815 $tag = new Tag();
816 $tag->setLabel('super');
817 $em->persist($tag);
818
819 $entry = new Entry($user);
820 $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');
821 $entry->setContent('Youhou');
822 $entry->setTitle('Youhou');
823 $entry->addTag($tag);
824 $em->persist($entry);
825
826 $annotation = new Annotation($user);
827 $annotation->setText('annotated');
828 $annotation->setQuote('annotated');
829 $annotation->setRanges([]);
830 $annotation->setEntry($entry);
831 $em->persist($annotation);
832
833 $tagArchived = new Tag();
834 $tagArchived->setLabel('super');
835 $em->persist($tagArchived);
836
837 $entryArchived = new Entry($user);
838 $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');
839 $entryArchived->setContent('Youhou');
840 $entryArchived->setTitle('Youhou');
841 $entryArchived->addTag($tagArchived);
842 $entryArchived->setArchived(true);
843 $em->persist($entryArchived);
844
845 $annotationArchived = new Annotation($user);
846 $annotationArchived->setText('annotated');
847 $annotationArchived->setQuote('annotated');
848 $annotationArchived->setRanges([]);
849 $annotationArchived->setEntry($entryArchived);
850 $em->persist($annotationArchived);
851
852 $em->flush();
853
854 $crawler = $client->request('GET', '/config#set3');
855
856 $this->assertEquals(200, $client->getResponse()->getStatusCode());
857
858 $crawler = $client->click($crawler->selectLink('config.reset.archived')->link());
859
860 $this->assertEquals(302, $client->getResponse()->getStatusCode());
861 $this->assertContains('flashes.config.notice.archived_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
862
863 $entryReset = $em
864 ->getRepository('WallabagCoreBundle:Entry')
865 ->countAllEntriesByUser($user->getId());
866
867 $this->assertEquals(1, $entryReset, 'Entries were reset');
868
869 $tagReset = $em
870 ->getRepository('WallabagCoreBundle:Tag')
871 ->countAllTags($user->getId());
872
873 $this->assertEquals(1, $tagReset, 'Tags were reset');
874
875 $annotationsReset = $em
876 ->getRepository('WallabagAnnotationBundle:Annotation')
877 ->findAnnotationsByPageId($annotationArchived->getId(), $user->getId());
878
879 $this->assertEmpty($annotationsReset, 'Annotations were reset');
880 }
881
806 public function testResetEntriesCascade() 882 public function testResetEntriesCascade()
807 { 883 {
808 $this->logInAs('empty'); 884 $this->logInAs('empty');