aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2017-03-30 16:24:59 +0200
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2017-03-31 10:46:05 +0200
commit6da1aebc946e6448dd0d5080ee88e79c2bae4666 (patch)
tree43d350623f225ee560e040cd361d628454f2b1a7 /tests/Wallabag
parentfa884b30ba0f8cb4231bd37fff23ef2f41ae6cfa (diff)
downloadwallabag-6da1aebc946e6448dd0d5080ee88e79c2bae4666.tar.gz
wallabag-6da1aebc946e6448dd0d5080ee88e79c2bae4666.tar.zst
wallabag-6da1aebc946e6448dd0d5080ee88e79c2bae4666.zip
Allow to remove all archived entries
Since we still support fucking SQLite, we need to retrieve all tags & annotations for archived entries before deleting them. Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'tests/Wallabag')
-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..b434a4c4 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 ->countAllEntriesByUsername($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');