diff options
author | Andres Rey <[email protected]> | 2016-12-07 12:15:13 +0000 |
---|---|---|
committer | Andres Rey <[email protected]> | 2016-12-07 12:15:13 +0000 |
commit | f2c652f680fc9630c3c3235adf3e669d2bd9f1b9 (patch) | |
tree | 367aa8c38d7ce60531345c940fb77939068a3a01 | |
parent | 3ec5546359239f66714ae6eb5257810877202a52 (diff) |
Refactored the testing suite a bit using data providers
-rw-r--r-- | test/HTMLParserTest.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/test/HTMLParserTest.php b/test/HTMLParserTest.php index 4de7d7e..7ad4238 100644 --- a/test/HTMLParserTest.php +++ b/test/HTMLParserTest.php @@ -7,7 +7,10 @@ use andreskrey\Readability\HTMLParser; class HTMLParserTest extends \PHPUnit_Framework_TestCase { - private function HTMLParserParsesHTML($html, $expectedResult, $expectedMetadata) + /** + * @dataProvider getSamplePages + */ + public function testHTMLParserParsesHTML($html, $expectedResult) { $readability = new HTMLParser(); $result = $readability->parse($html); @@ -15,17 +18,20 @@ class HTMLParserTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expectedResult, $result['html']); } - public function testSamplePages() + public function getSamplePages() { $path = pathinfo(__FILE__, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . 'test-pages'; $testPages = scandir($path); + $pages = []; + foreach(array_slice($testPages, 2) as $testPage){ $source = file_get_contents($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'source.html'); - $expectedMetadata = file_get_contents($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'expected-metadata.json'); $expectedHTML = file_get_contents($path . DIRECTORY_SEPARATOR . $testPage . DIRECTORY_SEPARATOR . 'expected.html'); - $this->HTMLParserParsesHTML($source, $expectedHTML, $expectedMetadata); + $pages[] = [$source, $expectedHTML]; } + + return $pages; } }
\ No newline at end of file |