diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/HTML5/Parser/DOMTreeBuilderTest.php | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php index 6ffae75..963000c 100644 --- a/test/HTML5/Parser/DOMTreeBuilderTest.php +++ b/test/HTML5/Parser/DOMTreeBuilderTest.php @@ -7,5 +7,27 @@ namespace HTML5\Parser; require_once __DIR__ . '/../TestCase.php'; -class DOMTreeParserTest extends \HTML5\Tests\TestCase { +class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { + + /** + * Convenience function for parsing. + */ + protected function parse($string) { + $treeBuilder = new DOMTreeBuilder(); + $input = new StringInputStream($string); + $scanner = new Scanner($input); + $parser = new Tokenizer($scanner, $treeBuilder); + + $parser->parse(); + + return $treeBuilder->document(); + } + + public function testDocument() { + $html = "<!DOCTYPE html><html></html>"; + $doc = $this->parse($html); + + $this->assertInstanceOf('\DOMDocument', $doc); + $this->assertEquals('html', $doc->documentElement->tagName); + } } |