aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/CoreBundle')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php26
-rw-r--r--tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php29
2 files changed, 37 insertions, 18 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 514e9d89..4ab06dbf 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -869,10 +869,30 @@ class EntryControllerTest extends WallabagCoreTestCase
869 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry); 869 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry);
870 $this->assertEquals($url, $entry->getUrl()); 870 $this->assertEquals($url, $entry->getUrl());
871 $this->assertContains('Perpignan', $entry->getTitle()); 871 $this->assertContains('Perpignan', $entry->getTitle());
872 $this->assertContains('assets/images/8/e/8ec9229a/d9bc0fcd.jpeg', $entry->getContent()); 872 $this->assertContains('/d9bc0fcd.jpeg', $entry->getContent());
873 873
874 $em->remove($entry); 874 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
875 $em->flush(); 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());
876 896
877 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0); 897 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
878 } 898 }
diff --git a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
index 33d2e389..920c21d9 100644
--- a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
@@ -26,12 +26,11 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
26 $logHandler = new TestHandler(); 26 $logHandler = new TestHandler();
27 $logger = new Logger('test', array($logHandler)); 27 $logger = new Logger('test', array($logHandler));
28 28
29 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', $logger); 29 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
30 $download->setWallabagUrl('http://wallabag.io/');
31 30
32 $res = $download->processHtml('<div><img src="http://i.imgur.com/T9qgcHc.jpg" /></div>', 'http://imgur.com/gallery/WxtWY'); 31 $res = $download->processHtml(123, '<div><img src="http://i.imgur.com/T9qgcHc.jpg" /></div>', 'http://imgur.com/gallery/WxtWY');
33 32
34 $this->assertContains('http://wallabag.io/assets/images/4/2/4258f71e/c638b4c2.png', $res); 33 $this->assertContains('http://wallabag.io/assets/images/9/b/9b0ead26/c638b4c2.png', $res);
35 } 34 }
36 35
37 public function testProcessHtmlWithBadImage() 36 public function testProcessHtmlWithBadImage()
@@ -47,8 +46,8 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
47 $logHandler = new TestHandler(); 46 $logHandler = new TestHandler();
48 $logger = new Logger('test', array($logHandler)); 47 $logger = new Logger('test', array($logHandler));
49 48
50 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', $logger); 49 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
51 $res = $download->processHtml('<div><img src="http://i.imgur.com/T9qgcHc.jpg" /></div>', 'http://imgur.com/gallery/WxtWY'); 50 $res = $download->processHtml(123, '<div><img src="http://i.imgur.com/T9qgcHc.jpg" /></div>', 'http://imgur.com/gallery/WxtWY');
52 51
53 $this->assertContains('http://i.imgur.com/T9qgcHc.jpg', $res, 'Image were not replace because of content-type'); 52 $this->assertContains('http://i.imgur.com/T9qgcHc.jpg', $res, 'Image were not replace because of content-type');
54 } 53 }
@@ -79,10 +78,10 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
79 $logHandler = new TestHandler(); 78 $logHandler = new TestHandler();
80 $logger = new Logger('test', array($logHandler)); 79 $logger = new Logger('test', array($logHandler));
81 80
82 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', $logger); 81 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
83 $res = $download->processSingleImage('T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY'); 82 $res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
84 83
85 $this->assertContains('/assets/images/4/2/4258f71e/ebe60399.'.$extension, $res); 84 $this->assertContains('/assets/images/9/b/9b0ead26/ebe60399.'.$extension, $res);
86 } 85 }
87 86
88 public function testProcessSingleImageWithBadUrl() 87 public function testProcessSingleImageWithBadUrl()
@@ -98,8 +97,8 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
98 $logHandler = new TestHandler(); 97 $logHandler = new TestHandler();
99 $logger = new Logger('test', array($logHandler)); 98 $logger = new Logger('test', array($logHandler));
100 99
101 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', $logger); 100 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
102 $res = $download->processSingleImage('T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY'); 101 $res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
103 102
104 $this->assertFalse($res, 'Image can not be found, so it will not be replaced'); 103 $this->assertFalse($res, 'Image can not be found, so it will not be replaced');
105 } 104 }
@@ -117,8 +116,8 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
117 $logHandler = new TestHandler(); 116 $logHandler = new TestHandler();
118 $logger = new Logger('test', array($logHandler)); 117 $logger = new Logger('test', array($logHandler));
119 118
120 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', $logger); 119 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
121 $res = $download->processSingleImage('http://i.imgur.com/T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY'); 120 $res = $download->processSingleImage(123, 'http://i.imgur.com/T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
122 121
123 $this->assertFalse($res, 'Image can not be loaded, so it will not be replaced'); 122 $this->assertFalse($res, 'Image can not be loaded, so it will not be replaced');
124 } 123 }
@@ -136,8 +135,8 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
136 $logHandler = new TestHandler(); 135 $logHandler = new TestHandler();
137 $logger = new Logger('test', array($logHandler)); 136 $logger = new Logger('test', array($logHandler));
138 137
139 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', $logger); 138 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
140 $res = $download->processSingleImage('/i.imgur.com/T9qgcHc.jpg', 'imgur.com/gallery/WxtWY'); 139 $res = $download->processSingleImage(123, '/i.imgur.com/T9qgcHc.jpg', 'imgur.com/gallery/WxtWY');
141 140
142 $this->assertFalse($res, 'Absolute image can not be determined, so it will not be replaced'); 141 $this->assertFalse($res, 'Absolute image can not be determined, so it will not be replaced');
143 } 142 }