blob: 4de7d7eca85819002cf293f53e69ad1911ae69be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<?php
namespace andreskrey\Readability\Test;
use andreskrey\Readability\HTMLParser;
class HTMLParserTest extends \PHPUnit_Framework_TestCase
{
private function HTMLParserParsesHTML($html, $expectedResult, $expectedMetadata)
{
$readability = new HTMLParser();
$result = $readability->parse($html);
$this->assertEquals($expectedResult, $result['html']);
}
public function testSamplePages()
{
$path = pathinfo(__FILE__, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . 'test-pages';
$testPages = scandir($path);
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);
}
}
}
|