class ReadabilityTest extends \PHPUnit_Framework_TestCase
class ReadabilityTest extends \PHPUnit_Framework_TestCase
{
{
@ -94,7 +94,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testInitDivP()
public function testInitDivP()
{
{
$readability = $this->getReadability('<div>'.str_repeat('<p>This is the awesome content :)</p>', 7).'</div>', 'http://0.0.0.0');
$readability = $this->getReadability('<div>'.str_repeat('<p>This is the awesome content :)</p>', 7).'</div>', 'http://0.0.0.0');
$res = $readability->init();
$res = $readability->init();
$this->assertTrue($res);
$this->assertTrue($res);
@ -107,7 +107,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testInitDiv()
public function testInitDiv()
{
{
$readability = $this->getReadability('<div>'.str_repeat('This is the awesome content :)', 7).'</div>', 'http://0.0.0.0');
$readability = $this->getReadability('<div>'.str_repeat('This is the awesome content :)', 7).'</div>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$res = $readability->init();
$res = $readability->init();
@ -121,7 +121,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithFootnotes()
public function testWithFootnotes()
{
{
$readability = $this->getReadability('<div>'.str_repeat('<p>This is an awesome text with some links, here there are: <ahref="http://0.0.0.0/test.html">the awesome</a></p>', 7).'</div>', 'http://0.0.0.0');
$readability = $this->getReadability('<div>'.str_repeat('<p>This is an awesome text with some links, here there are: <ahref="http://0.0.0.0/test.html">the awesome</a></p>', 7).'</div>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$readability->convertLinksToFootnotes = true;
$readability->convertLinksToFootnotes = true;
$res = $readability->init();
$res = $readability->init();
@ -138,7 +138,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testStandardClean()
public function testStandardClean()
{
{
$readability = $this->getReadability('<div><h2>Title</h2>'.str_repeat('<p>This is an awesome text with some links, here there are: <ahref="http://0.0.0.0/test.html">the awesome</a></p>', 7).'<ahref="#nofollow"rel="nofollow">will NOT be removed</a></div>', 'http://0.0.0.0');
$readability = $this->getReadability('<div><h2>Title</h2>'.str_repeat('<p>This is an awesome text with some links, here there are: <ahref="http://0.0.0.0/test.html">the awesome</a></p>', 7).'<ahref="#nofollow"rel="nofollow">will NOT be removed</a></div>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$readability->lightClean = false;
$readability->lightClean = false;
$res = $readability->init();
$res = $readability->init();
@ -155,7 +155,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithIframe()
public function testWithIframe()
{
{
$readability = $this->getReadability('<div><h2>Title</h2>'.str_repeat('<p>This is an awesome text with some links, here there are: <ahref="http://0.0.0.0/test.html">the awesome</a></p>', 7).'<p>This is an awesome text with some links, here there are <iframesrc="http://youtube.com/test"href="#nofollow"rel="nofollow"></iframe><iframe>http://soundcloud.com/test</iframe></p></div>', 'http://0.0.0.0');
$readability = $this->getReadability('<div><h2>Title</h2>'.str_repeat('<p>This is an awesome text with some links, here there are: <ahref="http://0.0.0.0/test.html">the awesome</a></p>', 7).'<p>This is an awesome text with some links, here there are <iframesrc="http://youtube.com/test"href="#nofollow"rel="nofollow"></iframe><iframe>http://soundcloud.com/test</iframe></p></div>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$res = $readability->init();
$res = $readability->init();
@ -170,7 +170,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithArticle()
public function testWithArticle()
{
{
$readability = $this->getReadability('<article><p>'.str_repeat('This is an awesome text with some links, here there are: the awesome', 20).'</p><p>This is an awesome text with some links, here there are <iframesrc="http://youtube.com/test"href="#nofollow"rel="nofollow"></iframe></p></article>', 'http://0.0.0.0');
$readability = $this->getReadability('<article><p>'.str_repeat('This is an awesome text with some links, here there are: the awesome', 20).'</p><p>This is an awesome text with some links, here there are <iframesrc="http://youtube.com/test"href="#nofollow"rel="nofollow"></iframe></p></article>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$res = $readability->init();
$res = $readability->init();
@ -185,7 +185,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithAside()
public function testWithAside()
{
{
$readability = $this->getReadability('<article>'.str_repeat('<p>This is an awesome text with some links, here there are: <ahref="http://0.0.0.0/test.html">the awesome</a></p>', 7).'<footer><aside>'.str_repeat('<p>This is an awesome text with some links, here there are</p>', 8).'</aside></footer></article>', 'http://0.0.0.0');
$readability = $this->getReadability('<article>'.str_repeat('<p>This is an awesome text with some links, here there are: <ahref="http://0.0.0.0/test.html">the awesome</a></p>', 7).'<footer><aside>'.str_repeat('<p>This is an awesome text with some links, here there are</p>', 8).'</aside></footer></article>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$res = $readability->init();
$res = $readability->init();
@ -200,7 +200,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithClasses()
public function testWithClasses()
{
{
$readability = $this->getReadability('<article>'.str_repeat('<p>This is an awesome text with some links, here there are: <ahref="http://0.0.0.0/test.html">the awesome</a></p>', 7).'<divstyle="display:none">'.str_repeat('<pclass="clock">This text should be removed</p>', 10).'</div></article>', 'http://0.0.0.0');
$readability = $this->getReadability('<article>'.str_repeat('<p>This is an awesome text with some links, here there are: <ahref="http://0.0.0.0/test.html">the awesome</a></p>', 7).'<divstyle="display:none">'.str_repeat('<pclass="clock">This text should be removed</p>', 10).'</div></article>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$res = $readability->init();
$res = $readability->init();
@ -215,7 +215,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithClassesWithoutLightClean()
public function testWithClassesWithoutLightClean()
{
{
$readability = $this->getReadability('<article>'.str_repeat('<p>This is an awesome text with some links, here there are: <ahref="http://0.0.0.0/test.html">the awesome</a></p>', 7).'<divstyle="display:none">'.str_repeat('<pclass="clock">This text should be removed</p>', 10).'</div></article>', 'http://0.0.0.0');
$readability = $this->getReadability('<article>'.str_repeat('<p>This is an awesome text with some links, here there are: <ahref="http://0.0.0.0/test.html">the awesome</a></p>', 7).'<divstyle="display:none">'.str_repeat('<pclass="clock">This text should be removed</p>', 10).'</div></article>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$readability->lightClean = false;
$readability->lightClean = false;
$res = $readability->init();
$res = $readability->init();
@ -231,7 +231,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithTd()
public function testWithTd()
{
{
$readability = $this->getReadability('<table><tr>'.str_repeat('<td><p>This is an awesome text with some links, here there are the awesome</td>', 7).'</tr></table>', 'http://0.0.0.0');
$readability = $this->getReadability('<table><tr>'.str_repeat('<td><p>This is an awesome text with some links, here there are the awesome</td>', 7).'</tr></table>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$res = $readability->init();
$res = $readability->init();
@ -244,7 +244,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithSameClasses()
public function testWithSameClasses()
{
{
$readability = $this->getReadability('<articleclass="awesomecontent">'.str_repeat('<p>This is an awesome text with some links, here there are the awesome</p>', 7).'<divclass="awesomecontent">This text is also an awesome text and you should know that !</div></article>', 'http://0.0.0.0');
$readability = $this->getReadability('<articleclass="awesomecontent">'.str_repeat('<p>This is an awesome text with some links, here there are the awesome</p>', 7).'<divclass="awesomecontent">This text is also an awesome text and you should know that !</div></article>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$res = $readability->init();
$res = $readability->init();
@ -258,7 +258,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithScript()
public function testWithScript()
{
{
$readability = $this->getReadability('<articleclass="awesomecontent">'.str_repeat('<p>This is an awesome text with some links, here there are the awesome</p>', 7).'<p><script>Thistextisalsoanawesometextandyoushouldknowthat!</script></p></article>', 'http://0.0.0.0');
$readability = $this->getReadability('<articleclass="awesomecontent">'.str_repeat('<p>This is an awesome text with some links, here there are the awesome</p>', 7).'<p><script>Thistextisalsoanawesometextandyoushouldknowthat!</script></p></article>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$res = $readability->init();
$res = $readability->init();
@ -272,7 +272,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testTitle()
public function testTitle()
{
{
$readability = $this->getReadability('<title>this is my title</title><articleclass="awesomecontent">'.str_repeat('<p>This is an awesome text with some links, here there are the awesome</p>', 7).'<p></p></article>', 'http://0.0.0.0');
$readability = $this->getReadability('<title>this is my title</title><articleclass="awesomecontent">'.str_repeat('<p>This is an awesome text with some links, here there are the awesome</p>', 7).'<p></p></article>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$res = $readability->init();
$res = $readability->init();
@ -286,7 +286,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testTitleWithDash()
public function testTitleWithDash()
{
{
$readability = $this->getReadability('<title> title2 - title3 </title><articleclass="awesomecontent">'.str_repeat('<p>This is an awesome text with some links, here there are the awesome</p>', 7).'<p></p></article>', 'http://0.0.0.0');
$readability = $this->getReadability('<title> title2 - title3 </title><articleclass="awesomecontent">'.str_repeat('<p>This is an awesome text with some links, here there are the awesome</p>', 7).'<p></p></article>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$res = $readability->init();
$res = $readability->init();
@ -300,7 +300,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testTitleWithDoubleDot()
public function testTitleWithDoubleDot()
{
{
$readability = $this->getReadability('<title> title2 : title3 </title><articleclass="awesomecontent">'.str_repeat('<p>This is an awesome text with some links, here there are the awesome</p>', 7).'<p></p></article>', 'http://0.0.0.0');
$readability = $this->getReadability('<title> title2 : title3 </title><articleclass="awesomecontent">'.str_repeat('<p>This is an awesome text with some links, here there are the awesome</p>', 7).'<p></p></article>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$res = $readability->init();
$res = $readability->init();
@ -314,7 +314,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testTitleTooShortUseH1()
public function testTitleTooShortUseH1()
{
{
$readability = $this->getReadability('<title>too short</title><h1>this is my h1 title !</h1><articleclass="awesomecontent">'.str_repeat('<p>This is an awesome text with some links, here there are the awesome</p>', 7).'<p></p></article>', 'http://0.0.0.0');
$readability = $this->getReadability('<title>too short</title><h1>this is my h1 title !</h1><articleclass="awesomecontent">'.str_repeat('<p>This is an awesome text with some links, here there are the awesome</p>', 7).'<p></p></article>', 'http://0.0.0.0');
$readability->debug = true;
$readability->debug = true;
$res = $readability->init();
$res = $readability->init();
@ -383,7 +383,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
}
}
/**
/**
* This should generate an Exception "DOMElement::setAttribute(): ID post-60 already defined"
* This should generate an Exception "DOMElement::setAttribute(): ID post-60 already defined".
*/
*/
public function testAppendIdAlreadyHere()
public function testAppendIdAlreadyHere()
{
{
@ -443,7 +443,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testPostFilters()
public function testPostFilters()
{
{
$readability = $this->getReadability('<div>'.str_repeat('<p>This <b>is</b> the awesome content :)</p>', 7).'</div>', 'http://0.0.0.0');
$readability = $this->getReadability('<div>'.str_repeat('<p>This <b>is</b> the awesome content :)</p>', 7).'</div>', 'http://0.0.0.0');