diff options
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller')
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 05113650..4ab06dbf 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -836,4 +836,64 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
836 | $client->request('GET', '/share/'.$content->getUuid()); | 836 | $client->request('GET', '/share/'.$content->getUuid()); |
837 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | 837 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); |
838 | } | 838 | } |
839 | |||
840 | public function testNewEntryWithDownloadImagesEnabled() | ||
841 | { | ||
842 | $this->logInAs('admin'); | ||
843 | $client = $this->getClient(); | ||
844 | |||
845 | $url = 'http://www.20minutes.fr/montpellier/1952003-20161030-video-car-tombe-panne-rugbymen-perpignan-improvisent-melee-route'; | ||
846 | $client->getContainer()->get('craue_config')->set('download_images_enabled', 1); | ||
847 | |||
848 | $crawler = $client->request('GET', '/new'); | ||
849 | |||
850 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
851 | |||
852 | $form = $crawler->filter('form[name=entry]')->form(); | ||
853 | |||
854 | $data = [ | ||
855 | 'entry[url]' => $url, | ||
856 | ]; | ||
857 | |||
858 | $client->submit($form, $data); | ||
859 | |||
860 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
861 | |||
862 | $em = $client->getContainer() | ||
863 | ->get('doctrine.orm.entity_manager'); | ||
864 | |||
865 | $entry = $em | ||
866 | ->getRepository('WallabagCoreBundle:Entry') | ||
867 | ->findByUrlAndUserId($url, $this->getLoggedInUserId()); | ||
868 | |||
869 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry); | ||
870 | $this->assertEquals($url, $entry->getUrl()); | ||
871 | $this->assertContains('Perpignan', $entry->getTitle()); | ||
872 | $this->assertContains('/d9bc0fcd.jpeg', $entry->getContent()); | ||
873 | |||
874 | $client->getContainer()->get('craue_config')->set('download_images_enabled', 0); | ||
875 | } | ||
876 | |||
877 | /** | ||
878 | * @depends testNewEntryWithDownloadImagesEnabled | ||
879 | */ | ||
880 | public function testRemoveEntryWithDownloadImagesEnabled() | ||
881 | { | ||
882 | $this->logInAs('admin'); | ||
883 | $client = $this->getClient(); | ||
884 | |||
885 | $url = 'http://www.20minutes.fr/montpellier/1952003-20161030-video-car-tombe-panne-rugbymen-perpignan-improvisent-melee-route'; | ||
886 | $client->getContainer()->get('craue_config')->set('download_images_enabled', 1); | ||
887 | |||
888 | $content = $client->getContainer() | ||
889 | ->get('doctrine.orm.entity_manager') | ||
890 | ->getRepository('WallabagCoreBundle:Entry') | ||
891 | ->findByUrlAndUserId($url, $this->getLoggedInUserId()); | ||
892 | |||
893 | $client->request('GET', '/delete/'.$content->getId()); | ||
894 | |||
895 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
896 | |||
897 | $client->getContainer()->get('craue_config')->set('download_images_enabled', 0); | ||
898 | } | ||
839 | } | 899 | } |