From f7b3b3e0d71dcf84b4be4699a25df95c29682e34 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 20 Nov 2017 15:44:34 +0100 Subject: Add test for getImages() --- test/HTMLParserTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test/HTMLParserTest.php') diff --git a/test/HTMLParserTest.php b/test/HTMLParserTest.php index ad6d943..96c07df 100644 --- a/test/HTMLParserTest.php +++ b/test/HTMLParserTest.php @@ -9,7 +9,7 @@ class HTMLParserTest extends \PHPUnit_Framework_TestCase /** * @dataProvider getSamplePages */ - public function testHTMLParserParsesHTML($html, $expectedResult, $expectedMetadata, $config) + public function testHTMLParserParsesHTML($html, $expectedResult, $expectedMetadata, $config, $expectedImages) { $options = ['originalURL' => 'http://fakehost/test/test.html', 'fixRelativeURLs' => true, @@ -24,6 +24,7 @@ class HTMLParserTest extends \PHPUnit_Framework_TestCase $result = $readability->parse($html); $this->assertEquals($expectedResult, $result['html']); + $this->assertEquals($expectedImages, json_encode($result['images'])); } public function getSamplePages() @@ -40,6 +41,7 @@ class HTMLParserTest extends \PHPUnit_Framework_TestCase $source = file_get_contents($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'source.html'); $expectedHTML = file_get_contents($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'expected.html'); $expectedMetadata = file_get_contents($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'expected-metadata.json'); + $expectedImages = file_get_contents($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'expected-images.json'); $config = null; if (file_exists($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'config.json')) { @@ -49,7 +51,7 @@ class HTMLParserTest extends \PHPUnit_Framework_TestCase } } - $pages[$testPage] = [$source, $expectedHTML, $expectedMetadata, $config]; + $pages[$testPage] = [$source, $expectedHTML, $expectedMetadata, $config, $expectedImages]; } return $pages; -- cgit v1.2.3