From e74a691624e81fe82a41bed02165afa4508b3101 Mon Sep 17 00:00:00 2001 From: Andres Rey Date: Fri, 1 Dec 2017 22:02:35 +0000 Subject: Add tests for exceptions --- test/ReadabilityTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/ReadabilityTest.php') 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(''); + } + + public function testReadabilityThrowsExceptionWithUnparseableHTML() + { + $parser = new Readability(new Configuration()); + $this->expectException(ParseException::class); + $this->expectExceptionMessage('Could not parse text.'); + $parser->parse('

hello

'); + } } -- cgit v1.2.3