summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ReadabilityTest.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ReadabilityTest.php b/test/ReadabilityTest.php
index 9d29ba5..28673d9 100644
--- a/test/ReadabilityTest.php
+++ b/test/ReadabilityTest.php
@@ -3,6 +3,7 @@
namespace andreskrey\Readability\Test;
use andreskrey\Readability\Configuration;
+use andreskrey\Readability\ParseException;
use andreskrey\Readability\Readability;
class ReadabilityTest extends \PHPUnit_Framework_TestCase
@@ -89,4 +90,20 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase
return $pages;
}
+
+ public function testReadabilityThrowsExceptionWithMalformedHTML()
+ {
+ $parser = new Readability(new Configuration());
+ $this->expectException(ParseException::class);
+ $this->expectExceptionMessage('Invalid or incomplete HTML.');
+ $parser->parse('<html>');
+ }
+
+ public function testReadabilityThrowsExceptionWithUnparseableHTML()
+ {
+ $parser = new Readability(new Configuration());
+ $this->expectException(ParseException::class);
+ $this->expectExceptionMessage('Could not parse text.');
+ $parser->parse('<html><body><p>hello</p></body></html>');
+ }
}