aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/CoreBundle/Helper/DownloadImages.php4
-rw-r--r--tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php23
2 files changed, 27 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/DownloadImages.php b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
index 9c9452dd..f91cdf5e 100644
--- a/src/Wallabag/CoreBundle/Helper/DownloadImages.php
+++ b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
@@ -85,6 +85,10 @@ class DownloadImages
85 */ 85 */
86 public function processSingleImage($entryId, $imagePath, $url, $relativePath = null) 86 public function processSingleImage($entryId, $imagePath, $url, $relativePath = null)
87 { 87 {
88 if (null === $imagePath) {
89 return false;
90 }
91
88 if (null === $relativePath) { 92 if (null === $relativePath) {
89 $relativePath = $this->getRelativePath($entryId); 93 $relativePath = $this->getRelativePath($entryId);
90 } 94 }
diff --git a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
index 51ab1bcd..faa803fa 100644
--- a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
@@ -204,4 +204,27 @@ class DownloadImagesTest extends TestCase
204 204
205 $this->assertNotContains('http://piketty.blog.lemonde.fr/', $res, 'Image srcset attribute were not replaced'); 205 $this->assertNotContains('http://piketty.blog.lemonde.fr/', $res, 'Image srcset attribute were not replaced');
206 } 206 }
207
208 public function testProcessImageWithNullPath()
209 {
210 $client = new Client();
211
212 $mock = new Mock([
213 new Response(200, ['content-type' => null], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))),
214 ]);
215
216 $client->getEmitter()->attach($mock);
217
218 $logHandler = new TestHandler();
219 $logger = new Logger('test', [$logHandler]);
220
221 $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
222
223 $res = $download->processSingleImage(
224 123,
225 null,
226 'https://framablog.org/2018/06/30/engagement-atypique/'
227 );
228 $this->assertFalse($res);
229 }
207} 230}