diff options
author | Pedro Amorim <[email protected]> | 2017-11-20 15:44:34 +0100 |
---|---|---|
committer | Pedro Amorim <[email protected]> | 2017-11-23 10:55:52 +0100 |
commit | f7b3b3e0d71dcf84b4be4699a25df95c29682e34 (patch) | |
tree | fe83040d5557635e598b5ff5acb966fdf7d25f4c /test/HTMLParserTest.php | |
parent | 72a26f10493ceb677fdfc50823d44ca759301175 (diff) |
Add test for getImages()
Diffstat (limited to 'test/HTMLParserTest.php')
-rw-r--r-- | test/HTMLParserTest.php | 6 |
1 files changed, 4 insertions, 2 deletions
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; |