From c15bb5ad72b1a9692682cf88318a70b7e650d34a Mon Sep 17 00:00:00 2001 From: Simounet Date: Thu, 31 May 2018 23:42:06 +0200 Subject: Fix srcset attribute on images downloaded --- .../CoreBundle/Helper/DownloadImagesTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/Wallabag/CoreBundle') 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 $this->assertContains('http://wallabag.io/assets/images/9/b/9b0ead26/', $res, 'Content-Type was empty but data is ok for an image'); $this->assertContains('DownloadImages: Checking extension (alternative)', $logHandler->getRecords()[3]['message']); } + + public function testProcessImageWithSrcset() + { + $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, '

', 'http://piketty.blog.lemonde.fr/2017/10/12/budget-2018-la-jeunesse-sacrifiee/'); + + $this->assertNotContains('http://piketty.blog.lemonde.fr/', $res, 'Image srcset attribute were not replaced'); + } } -- cgit v1.2.3 From 778543311f5efde4c99321f257c5a9c34a7dea5f Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 6 Jun 2018 17:34:20 +0200 Subject: Fix tests --- .../Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php | 2 +- tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php | 2 +- tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php | 8 ++++---- tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | 10 +++++----- tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | 1 - 5 files changed, 11 insertions(+), 12 deletions(-) (limited to 'tests/Wallabag/CoreBundle') diff --git a/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php b/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php index 38e8dd07..5ca9785d 100644 --- a/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php @@ -60,7 +60,7 @@ class CleanDuplicatesCommandTest extends WallabagCoreTestCase public function testDuplicate() { - $url = 'http://www.lemonde.fr/sport/visuel/2017/05/05/rondelle-prison-blanchissage-comprendre-le-hockey-sur-glace_5122587_3242.html'; + $url = 'https://www.lemonde.fr/sport/visuel/2017/05/05/rondelle-prison-blanchissage-comprendre-le-hockey-sur-glace_5122587_3242.html'; $client = $this->getClient(); $em = $client->getContainer()->get('doctrine.orm.entity_manager'); diff --git a/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php b/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php index 63c068b4..b13f6519 100644 --- a/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php @@ -10,7 +10,7 @@ use Wallabag\CoreBundle\Entity\Entry; class ReloadEntryCommandTest extends WallabagCoreTestCase { - public $url = 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html'; + public $url = 'https://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html'; /** * @var entry diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index e4bf0998..e07c57dd 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php @@ -742,7 +742,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $em->persist($tag); $entry = new Entry($user); - $entry->setUrl('http://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html'); + $entry->setUrl('https://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html'); $entry->setContent('Youhou'); $entry->setTitle('Youhou'); $entry->addTag($tag); @@ -827,7 +827,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $em->persist($tag); $entry = new Entry($user); - $entry->setUrl('http://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html'); + $entry->setUrl('https://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html'); $entry->setContent('Youhou'); $entry->setTitle('Youhou'); $entry->addTag($tag); @@ -845,7 +845,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $em->persist($tagArchived); $entryArchived = new Entry($user); - $entryArchived->setUrl('http://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html'); + $entryArchived->setUrl('https://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html'); $entryArchived->setContent('Youhou'); $entryArchived->setTitle('Youhou'); $entryArchived->addTag($tagArchived); @@ -903,7 +903,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $em->persist($tag); $entry = new Entry($user); - $entry->setUrl('http://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html'); + $entry->setUrl('https://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html'); $entry->setContent('Youhou'); $entry->setTitle('Youhou'); $entry->addTag($tag); diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 95482fe4..a436be79 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -11,9 +11,9 @@ use Wallabag\CoreBundle\Helper\ContentProxy; class EntryControllerTest extends WallabagCoreTestCase { - const AN_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE = 'http://www.lemonde.fr/judo/article/2017/11/11/judo-la-decima-de-teddy-riner_5213605_1556020.html'; + const AN_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE = 'https://www.lemonde.fr/judo/article/2017/11/11/judo-la-decima-de-teddy-riner_5213605_1556020.html'; public $downloadImagesEnabled = false; - public $url = 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html'; + public $url = 'https://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html'; /** * @after @@ -1143,7 +1143,7 @@ class EntryControllerTest extends WallabagCoreTestCase $client = $this->getClient(); $entry = new Entry($this->getLoggedInUser()); - $entry->setUrl('http://www.lemonde.fr/incorrect-url/'); + $entry->setUrl('https://www.lemonde.fr/incorrect-url/'); $entry->setHttpStatus(404); $this->getEntityManager()->persist($entry); @@ -1342,8 +1342,8 @@ class EntryControllerTest extends WallabagCoreTestCase null, ], 'es-ES' => [ - 'https://www.muylinux.com/2015/04/17/odf-reino-unido-microsoft-google/', - 'es_ES', + 'https://www.20minutos.es/noticia/3360685/0/gobierno-sanchez-primero-historia-mas-mujeres-que-hombres/', + 'es', ], ]; } diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php index 398592e1..51df8de1 100644 --- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php @@ -11,7 +11,6 @@ use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\Validator\RecursiveValidator; use Wallabag\CoreBundle\Entity\Entry; -use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Helper\ContentProxy; use Wallabag\CoreBundle\Helper\RuleBasedTagger; use Wallabag\UserBundle\Entity\User; -- cgit v1.2.3