From 3fbbe0d9f1887d939fdb56733612f8ab0971deaf Mon Sep 17 00:00:00 2001 From: Simounet Date: Sun, 3 Jun 2018 22:52:48 +0200 Subject: Fix image downloading on null image path --- .../CoreBundle/Helper/DownloadImagesTest.php | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/Wallabag/CoreBundle') 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 $this->assertNotContains('http://piketty.blog.lemonde.fr/', $res, 'Image srcset attribute were not replaced'); } + + public function testProcessImageWithNullPath() + { + $client = new Client(); + + $mock = new Mock([ + new Response(200, ['content-type' => null], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))), + ]); + + $client->getEmitter()->attach($mock); + + $logHandler = new TestHandler(); + $logger = new Logger('test', [$logHandler]); + + $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger); + + $res = $download->processSingleImage( + 123, + null, + 'https://framablog.org/2018/06/30/engagement-atypique/' + ); + $this->assertFalse($res); + } } -- cgit v1.2.3 From e6f12c073416eba6fc620f0ff38a343bda428280 Mon Sep 17 00:00:00 2001 From: Simounet Date: Wed, 11 Jul 2018 19:57:34 +0200 Subject: More robust srcset image attribute handling Linked to HTMLawed PR https://github.com/kesar/HTMLawed/pull/17 --- .../CoreBundle/Helper/DownloadImagesTest.php | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/Wallabag/CoreBundle') diff --git a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php index faa803fa..cda5f843 100644 --- a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php +++ b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php @@ -205,6 +205,31 @@ class DownloadImagesTest extends TestCase $this->assertNotContains('http://piketty.blog.lemonde.fr/', $res, 'Image srcset attribute were not replaced'); } + public function testProcessImageWithTrickySrcset() + { + $client = new Client(); + + $mock = new Mock([ + new Response(200, ['content-type' => 'image/jpeg'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))), + new Response(200, ['content-type' => 'image/jpeg'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))), + new Response(200, ['content-type' => 'image/jpeg'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))), + ]); + + $client->getEmitter()->attach($mock); + + $logHandler = new TestHandler(); + $logger = new Logger('test', [$logHandler]); + + $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger); + $res = $download->processHtml(123, '
', 'https://css-tricks.com/the-critical-request/'); + + $this->assertNotContains('f_auto,q_auto', $res, 'Image srcset attribute were not replaced'); + } + public function testProcessImageWithNullPath() { $client = new Client(); -- cgit v1.2.3 From 72efc80fdc919656cf50a0432eec1ba58fda0ef2 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 19 Aug 2018 16:38:48 +0200 Subject: Removing failing test from Travis --- tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests/Wallabag/CoreBundle') diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index a436be79..6721b2e4 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -1325,10 +1325,6 @@ class EntryControllerTest extends WallabagCoreTestCase 'http://www.hao123.com/shequ?__noscript__-=1', 'zh_CN', ], - 'de_AT' => [ - 'https://buy.garmin.com/de-AT/AT/catalog/product/compareResult.ep?compareProduct=112885&compareProduct=36728', - 'de_AT', - ], 'ru_RU' => [ 'http://netler.ru/ikt/windows-error-reporting.htm', 'ru_RU', -- cgit v1.2.3 From 2a1ceb67b4400f46f4d3067e887ff54aa906f0a2 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Wed, 5 Sep 2018 14:25:32 +0200 Subject: php-cs-fixer Signed-off-by: Kevin Decherf --- tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | 2 +- tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | 4 ++-- tests/Wallabag/CoreBundle/Controller/TagControllerTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/Wallabag/CoreBundle') diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 6721b2e4..6a4c775b 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -524,7 +524,7 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); $this->assertContains('My updated title hehe :)', $title[0]); - $this->assertSame(1, count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']))); + $this->assertSame(1, \count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']))); $this->assertNotContains('example.io', trim($stats[0])); } diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php index ab7f23cc..6f3308e5 100644 --- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php @@ -180,7 +180,7 @@ class ExportControllerTest extends WallabagCoreTestCase $this->assertGreaterThan(1, $csv); // +1 for title line - $this->assertSame(count($contentInDB) + 1, count($csv)); + $this->assertSame(\count($contentInDB) + 1, \count($csv)); $this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); $this->assertContains($contentInDB[0]['title'], $csv[1]); $this->assertContains($contentInDB[0]['url'], $csv[1]); @@ -272,7 +272,7 @@ class ExportControllerTest extends WallabagCoreTestCase $content = new \SimpleXMLElement($client->getResponse()->getContent()); $this->assertGreaterThan(0, $content->count()); - $this->assertSame(count($contentInDB), $content->count()); + $this->assertSame(\count($contentInDB), $content->count()); $this->assertNotEmpty('id', (string) $content->entry[0]->id); $this->assertNotEmpty('title', (string) $content->entry[0]->title); $this->assertNotEmpty('url', (string) $content->entry[0]->url); diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php index 5a973a7e..768f4c07 100644 --- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php @@ -98,7 +98,7 @@ class TagControllerTest extends WallabagCoreTestCase $tags[$key] = $tag->getLabel(); } - $this->assertGreaterThanOrEqual(2, count($tags)); + $this->assertGreaterThanOrEqual(2, \count($tags)); $this->assertNotFalse(array_search('foo2', $tags, true), 'Tag foo2 is assigned to the entry'); $this->assertNotFalse(array_search('bar2', $tags, true), 'Tag bar2 is assigned to the entry'); } -- cgit v1.2.3