@ -83,7 +74,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testInitP()
public function testInitP()
{
{
$readability = new ReadabilityTested(str_repeat('<p>This is the awesome content :)</p>', 7), 'http://0.0.0.0');
$readability = $this->getReadability(str_repeat('<p>This is the awesome content :)</p>', 7), 'http://0.0.0.0');
$res = $readability->init();
$res = $readability->init();
$this->assertTrue($res);
$this->assertTrue($res);
@ -96,7 +87,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testInitDivP()
public function testInitDivP()
{
{
$readability = new ReadabilityTested('<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);
@ -109,7 +100,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testInitDiv()
public function testInitDiv()
{
{
$readability = new ReadabilityTested('<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();
@ -123,7 +114,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithFootnotes()
public function testWithFootnotes()
{
{
$readability = new ReadabilityTested('<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();
@ -140,7 +131,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testStandardClean()
public function testStandardClean()
{
{
$readability = new ReadabilityTested('<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();
@ -157,7 +148,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithIframe()
public function testWithIframe()
{
{
$readability = new ReadabilityTested('<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();
@ -172,7 +163,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithArticle()
public function testWithArticle()
{
{
$readability = new ReadabilityTested('<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();
@ -187,7 +178,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithAside()
public function testWithAside()
{
{
$readability = new ReadabilityTested('<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();
@ -202,7 +193,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithClasses()
public function testWithClasses()
{
{
$readability = new ReadabilityTested('<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();
@ -217,7 +208,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithClassesWithoutLightClean()
public function testWithClassesWithoutLightClean()
{
{
$readability = new ReadabilityTested('<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();
@ -233,7 +224,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithTd()
public function testWithTd()
{
{
$readability = new ReadabilityTested('<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();
@ -246,7 +237,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithSameClasses()
public function testWithSameClasses()
{
{
$readability = new ReadabilityTested('<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();
@ -260,7 +251,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testWithScript()
public function testWithScript()
{
{
$readability = new ReadabilityTested('<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();
@ -274,7 +265,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testTitle()
public function testTitle()
{
{
$readability = new ReadabilityTested('<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();
@ -288,7 +279,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testTitleWithDash()
public function testTitleWithDash()
{
{
$readability = new ReadabilityTested('<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();
@ -302,7 +293,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testTitleWithDoubleDot()
public function testTitleWithDoubleDot()
{
{
$readability = new ReadabilityTested('<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();
@ -316,7 +307,7 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
public function testTitleTooShortUseH1()
public function testTitleTooShortUseH1()
{
{
$readability = new ReadabilityTested('<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();
@ -330,13 +321,9 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
// public function testConstructParser()
// public function testConstructParser()
// {
// {
// $readability = new ReadabilityTested('<html/>', 'http://0.0.0.0', 'html5lib');