getReadability(''); $this->assertNull($readability->url); $this->assertInstanceOf('DomDocument', $readability->dom); } public function testConstructHtml5Parser() { $readability = $this->getReadability('', 'http://0.0.0.0', 'html5lib'); $this->assertEquals('http://0.0.0.0', $readability->url); $this->assertInstanceOf('DomDocument', $readability->dom); $this->assertEquals('', $readability->original_html); } /** * @requires extension tidy */ public function testConstructSimple() { $readability = $this->getReadability('', 'http://0.0.0.0'); $this->assertEquals('http://0.0.0.0', $readability->url); $this->assertInstanceOf('DomDocument', $readability->dom); $this->assertEquals('', $readability->original_html); $this->assertTrue($readability->tidied); } public function testConstructDefaultWithoutTidy() { $readability = $this->getReadability('', null, 'libxml', false); $this->assertNull($readability->url); $this->assertEquals('', $readability->original_html); $this->assertFalse($readability->tidied); $this->assertInstanceOf('DomDocument', $readability->dom); } public function testConstructSimpleWithoutTidy() { $readability = $this->getReadability('', 'http://0.0.0.0', 'libxml', false); $this->assertEquals('http://0.0.0.0', $readability->url); $this->assertInstanceOf('DomDocument', $readability->dom); $this->assertEquals('', $readability->original_html); $this->assertFalse($readability->tidied); } public function testInitNoContent() { $readability = $this->getReadability('', 'http://0.0.0.0'); $res = $readability->init(); $this->assertFalse($res); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent()); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle()); $this->assertEmpty($readability->getTitle()->getInnerHtml()); $this->assertContains('Sorry, Readability was unable to parse this page for content.', $readability->getContent()->getInnerHtml()); } public function testInitP() { $readability = $this->getReadability(str_repeat('

This is the awesome content :)

', 7), 'http://0.0.0.0'); $res = $readability->init(); $this->assertTrue($res); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent()); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle()); $this->assertContains('
getContent()->getInnerHtml()); } public function testInitDivP() { $readability = $this->getReadability('
' . str_repeat('

This is the awesome content :)

', 7) . '
', 'http://0.0.0.0'); $res = $readability->init(); $this->assertTrue($res); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent()); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle()); $this->assertContains('
getContent()->getInnerHtml()); } public function testInitDiv() { $readability = $this->getReadability('
' . str_repeat('This is the awesome content :)', 7) . '
', 'http://0.0.0.0'); $readability->debug = true; $res = $readability->init(); $this->assertTrue($res); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent()); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle()); $this->assertContains('
getContent()->getInnerHtml()); } public function testWithFootnotes() { $readability = $this->getReadability('
' . str_repeat('

This is an awesome text with some links, here there are: the awesome

', 7) . '
', 'http://0.0.0.0'); $readability->debug = true; $readability->convertLinksToFootnotes = true; $res = $readability->init(); $this->assertTrue($res); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent()); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle()); $this->assertContains('
getContent()->getInnerHtml()); $this->assertContains('readabilityFootnoteLink', $readability->getContent()->getInnerHtml()); $this->assertContains('readabilityLink-3', $readability->getContent()->getInnerHtml()); } public function testStandardClean() { $readability = $this->getReadability('

Title

' . str_repeat('

This is an awesome text with some links, here there are: the awesome

', 7) . 'will NOT be removed
', 'http://0.0.0.0'); $readability->debug = true; $readability->lightClean = false; $res = $readability->init(); $this->assertTrue($res); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent()); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle()); $this->assertContains('
getContent()->getInnerHtml()); $this->assertContains('will NOT be removed', $readability->getContent()->getInnerHtml()); $this->assertNotContains('

', $readability->getContent()->getInnerHtml()); } public function testWithIframe() { $readability = $this->getReadability('

Title

' . str_repeat('

This is an awesome text with some links, here there are: the awesome

', 7) . '

This is an awesome text with some links, here there are

', 'http://0.0.0.0'); $readability->debug = true; $res = $readability->init(); $this->assertTrue($res); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent()); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle()); $this->assertContains('
getContent()->getInnerHtml()); $this->assertContains('nofollow', $readability->getContent()->getInnerHtml()); } public function testWithArticle() { $readability = $this->getReadability('

' . str_repeat('This is an awesome text with some links, here there are: the awesome', 20) . '

This is an awesome text with some links, here there are

', 'http://0.0.0.0'); $readability->debug = true; $res = $readability->init(); $this->assertTrue($res); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent()); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle()); $this->assertContains('alt="article"', $readability->getContent()->getInnerHtml()); $this->assertEmpty($readability->getTitle()->getInnerHtml()); $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml()); $this->assertContains('nofollow', $readability->getContent()->getInnerHtml()); } public function testWithAside() { $readability = $this->getReadability('
' . str_repeat('

This is an awesome text with some links, here there are: the awesome

', 7) . '
', 'http://0.0.0.0'); $readability->debug = true; $res = $readability->init(); $this->assertTrue($res); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent()); $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle()); $this->assertEmpty($readability->getTitle()->getInnerHtml()); $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml()); $this->assertNotContains('