debugText; } public function getDomainRegexp() { return $this->domainRegExp; } } class ReadabilityTest extends \PHPUnit_Framework_TestCase { public function testConstructDefault() { $readability = new ReadabilityTested(''); $this->assertNull($readability->url); $this->assertContains('Parsing URL', $readability->getDebugText()); $this->assertContains('Tidying document', $readability->getDebugText()); $this->assertNull($readability->getDomainRegexp()); $this->assertInstanceOf('DomDocument', $readability->dom); } public function testConstructSimple() { $readability = new ReadabilityTested('', 'http://0.0.0.0'); $this->assertEquals('http://0.0.0.0', $readability->url); $this->assertContains('Parsing URL', $readability->getDebugText()); $this->assertContains('Tidying document', $readability->getDebugText()); $this->assertEquals('/0\.0\.0\.0/', $readability->getDomainRegexp()); $this->assertInstanceOf('DomDocument', $readability->dom); } public function testInitNoContent() { $readability = new ReadabilityTested('', '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()->innerHTML); $this->assertContains('Sorry, Readability was unable to parse this page for content.', $readability->getContent()->innerHTML); } public function testInitP() { $readability = new ReadabilityTested(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()->innerHTML); } public function testInitDivP() { $readability = new ReadabilityTested('
'.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()->innerHTML); } public function testInitDiv() { $readability = new ReadabilityTested('
'.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()->innerHTML); } public function testWithFootnotes() { $readability = new ReadabilityTested('
'.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()->innerHTML); $this->assertContains('readabilityFootnoteLink', $readability->getContent()->innerHTML); $this->assertContains('readabilityLink-3', $readability->getContent()->innerHTML); } public function testStandardClean() { $readability = new ReadabilityTested('

Title

'.str_repeat('

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

', 7).'will 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()->innerHTML); $this->assertNotContains('will be removed', $readability->getContent()->innerHTML); $this->assertNotContains('

', $readability->getContent()->innerHTML); } public function testWithIframe() { $readability = new ReadabilityTested('

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()->innerHTML); $this->assertContains('nofollow', $readability->getContent()->innerHTML); } public function testWithArticle() { $readability = new ReadabilityTested('

'.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()->innerHTML); $this->assertEmpty($readability->getTitle()->innerHTML); $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->innerHTML); $this->assertContains('nofollow', $readability->getContent()->innerHTML); } public function testWithAside() { $readability = new ReadabilityTested('
'.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->assertContains('alt="article"', $readability->getContent()->innerHTML); $this->assertEmpty($readability->getTitle()->innerHTML); $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->innerHTML); $this->assertNotContains('