aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php')
-rw-r--r--tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
index 51ab1bcd..cda5f843 100644
--- a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
@@ -204,4 +204,52 @@ 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 testProcessImageWithTrickySrcset()
209 {
210 $client = new Client();
211
212 $mock = new Mock([
213 new Response(200, ['content-type' => 'image/jpeg'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))),
214 new Response(200, ['content-type' => 'image/jpeg'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))),
215 new Response(200, ['content-type' => 'image/jpeg'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))),
216 ]);
217
218 $client->getEmitter()->attach($mock);
219
220 $logHandler = new TestHandler();
221 $logger = new Logger('test', [$logHandler]);
222
223 $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
224 $res = $download->processHtml(123, '<figure id="post-257260" class="align-none media-257260"><img src="https://cdn.css-tricks.com/wp-content/uploads/2017/08/the-critical-request.png" srcset="https://res.cloudinary.com/css-tricks/image/upload/c_scale,w_1000,f_auto,q_auto/v1501594717/the-critical-request_bqdfaa.png 1000w, https://res.cloudinary.com/css-tricks/image/upload/c_scale,w_200,f_auto,q_auto/v1501594717/the-critical-request_bqdfaa.png 200w" sizes="(min-width: 1850px) calc( (100vw - 555px) / 3 )
225 (min-width: 1251px) calc( (100vw - 530px) / 2 )
226 (min-width: 1086px) calc(100vw - 480px)
227 (min-width: 626px) calc(100vw - 335px)
228 calc(100vw - 30px)" alt="" /></figure>', 'https://css-tricks.com/the-critical-request/');
229
230 $this->assertNotContains('f_auto,q_auto', $res, 'Image srcset attribute were not replaced');
231 }
232
233 public function testProcessImageWithNullPath()
234 {
235 $client = new Client();
236
237 $mock = new Mock([
238 new Response(200, ['content-type' => null], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))),
239 ]);
240
241 $client->getEmitter()->attach($mock);
242
243 $logHandler = new TestHandler();
244 $logger = new Logger('test', [$logHandler]);
245
246 $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
247
248 $res = $download->processSingleImage(
249 123,
250 null,
251 'https://framablog.org/2018/06/30/engagement-atypique/'
252 );
253 $this->assertFalse($res);
254 }
207} 255}