diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2018-06-01 14:53:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-01 14:53:04 +0200 |
commit | 8fe73e076c75f185e44ee992e6f2ec6157aecf8e (patch) | |
tree | 778558ec77177019596ccd2c356d24b1b6074936 /tests/Wallabag | |
parent | 9707ac46613eea0c536d87f4c141d567fc2ef7d0 (diff) | |
parent | c15bb5ad72b1a9692682cf88318a70b7e650d34a (diff) | |
download | wallabag-8fe73e076c75f185e44ee992e6f2ec6157aecf8e.tar.gz wallabag-8fe73e076c75f185e44ee992e6f2ec6157aecf8e.tar.zst wallabag-8fe73e076c75f185e44ee992e6f2ec6157aecf8e.zip |
Merge pull request #3661 from Simounet/fix/2981-srcset-image
Fix srcset attribute on images downloaded
Diffstat (limited to 'tests/Wallabag')
-rw-r--r-- | tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php index 0e1d296b..51ab1bcd 100644 --- a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php +++ b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php | |||
@@ -183,4 +183,25 @@ class DownloadImagesTest extends TestCase | |||
183 | $this->assertContains('http://wallabag.io/assets/images/9/b/9b0ead26/', $res, 'Content-Type was empty but data is ok for an image'); | 183 | $this->assertContains('http://wallabag.io/assets/images/9/b/9b0ead26/', $res, 'Content-Type was empty but data is ok for an image'); |
184 | $this->assertContains('DownloadImages: Checking extension (alternative)', $logHandler->getRecords()[3]['message']); | 184 | $this->assertContains('DownloadImages: Checking extension (alternative)', $logHandler->getRecords()[3]['message']); |
185 | } | 185 | } |
186 | |||
187 | public function testProcessImageWithSrcset() | ||
188 | { | ||
189 | $client = new Client(); | ||
190 | |||
191 | $mock = new Mock([ | ||
192 | new Response(200, ['content-type' => 'image/jpeg'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))), | ||
193 | new Response(200, ['content-type' => 'image/jpeg'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))), | ||
194 | new Response(200, ['content-type' => 'image/jpeg'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))), | ||
195 | ]); | ||
196 | |||
197 | $client->getEmitter()->attach($mock); | ||
198 | |||
199 | $logHandler = new TestHandler(); | ||
200 | $logger = new Logger('test', [$logHandler]); | ||
201 | |||
202 | $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger); | ||
203 | $res = $download->processHtml(123, '<p><img class="alignnone wp-image-1153" src="http://piketty.blog.lemonde.fr/files/2017/10/F1FR-530x375.jpg" alt="" width="628" height="444" srcset="http://piketty.blog.lemonde.fr/files/2017/10/F1FR-530x375.jpg 530w, http://piketty.blog.lemonde.fr/files/2017/10/F1FR-768x543.jpg 768w, http://piketty.blog.lemonde.fr/files/2017/10/F1FR-900x636.jpg 900w" sizes="(max-width: 628px) 100vw, 628px" /></p>', 'http://piketty.blog.lemonde.fr/2017/10/12/budget-2018-la-jeunesse-sacrifiee/'); | ||
204 | |||
205 | $this->assertNotContains('http://piketty.blog.lemonde.fr/', $res, 'Image srcset attribute were not replaced'); | ||
206 | } | ||
186 | } | 207 | } |