diff options
author | Andres Rey <[email protected]> | 2017-12-01 22:02:35 +0000 |
---|---|---|
committer | Andres Rey <[email protected]> | 2017-12-01 22:02:35 +0000 |
commit | e74a691624e81fe82a41bed02165afa4508b3101 (patch) | |
tree | bdbb88008b71cd47c28f0bef9a9e9991660ee4a2 /test | |
parent | 3a644e0bd01215b7ac101c08f5ad6223a42888bc (diff) |
Add tests for exceptions
Diffstat (limited to 'test')
-rw-r--r-- | test/ReadabilityTest.php | 17 |
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>'); + } } |