mirror of
https://github.com/j0k3r/php-readability.git
synced 2026-09-27 06:26:17 +00:00
Revert BC changes
- avoid method signature update - revert moving logic out of the constructor
This commit is contained in:
+19
-10
@@ -22,40 +22,47 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
|
||||
return $readability;
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension tidy
|
||||
*/
|
||||
public function testConstructDefault()
|
||||
{
|
||||
$readability = $this->getReadability('');
|
||||
|
||||
$this->assertNull($readability->url);
|
||||
$this->assertInstanceOf('DomDocument', $readability->dom);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension tidy
|
||||
*/
|
||||
public function testConstructSimple()
|
||||
{
|
||||
$readability = $this->getReadability('<html/>', 'http://0.0.0.0');
|
||||
$readability->init();
|
||||
|
||||
$this->assertEquals('http://0.0.0.0', $readability->url);
|
||||
$this->assertInstanceOf('DomDocument', $readability->dom);
|
||||
$this->assertEquals('<html/>', $readability->original_html);
|
||||
$this->assertTrue($readability->tidied);
|
||||
|
||||
$this->assertTrue($this->logHandler->hasDebugThatContains('Parsing URL: http://0.0.0.0'));
|
||||
$this->assertTrue($this->logHandler->hasDebugThatContains('Tidying document'));
|
||||
$this->assertTrue($this->logHandler->hasDebugThatContains('Light clean enabled.'));
|
||||
}
|
||||
|
||||
public function testConstructDefaultWithoutTidy()
|
||||
{
|
||||
$readability = $this->getReadability('', null, 'libxml', false);
|
||||
$readability->init();
|
||||
|
||||
$this->assertNull($readability->url);
|
||||
$this->assertEquals('', $readability->original_html);
|
||||
$this->assertFalse($readability->tidied);
|
||||
|
||||
$this->assertTrue($this->logHandler->hasDebugThatContains('Parsing URL: '));
|
||||
$this->assertFalse($this->logHandler->hasDebugThatContains('Tidying document'));
|
||||
$this->assertTrue($this->logHandler->hasDebugThatContains('Light clean enabled.'));
|
||||
$this->assertInstanceOf('DomDocument', $readability->dom);
|
||||
}
|
||||
|
||||
public function testConstructSimpleWithoutTidy()
|
||||
{
|
||||
$readability = $this->getReadability('<html/>', 'http://0.0.0.0', 'libxml', false);
|
||||
$readability->init();
|
||||
|
||||
$this->assertEquals('http://0.0.0.0', $readability->url);
|
||||
$this->assertInstanceOf('DomDocument', $readability->dom);
|
||||
$this->assertEquals('<html/>', $readability->original_html);
|
||||
$this->assertFalse($readability->tidied);
|
||||
}
|
||||
@@ -447,6 +454,8 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testPreFilters()
|
||||
{
|
||||
$this->markTestSkipped('Won\'t work until loadHtml() is moved in init() instead of __construct()');
|
||||
|
||||
$readability = $this->getReadability('<div>'.str_repeat('<p>This <b>is</b> the awesome and WONDERFUL content :)</p>', 7).'</div>', 'http://0.0.0.0');
|
||||
$readability->addPreFilter('!<b[^>]*>(.*?)</b>!is', '');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user