diff options
Diffstat (limited to 'test/HTML5/Parser')
-rw-r--r-- | test/HTML5/Parser/DOMTreeBuilderTest.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php index ed8e70e..6947f8d 100644 --- a/test/HTML5/Parser/DOMTreeBuilderTest.php +++ b/test/HTML5/Parser/DOMTreeBuilderTest.php @@ -27,6 +27,16 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { return $treeBuilder->document(); } + protected function parseFragment($string) { + $treeBuilder = new DOMTreeBuilder(); + $input = new StringInputStream($string); + $scanner = new Scanner($input); + $parser = new Tokenizer($scanner, $treeBuilder); + + $parser->parse(); + + return $treeBuilder->fragment(); + } public function testDocument() { $html = "<!DOCTYPE html><html></html>"; @@ -36,6 +46,15 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { $this->assertEquals('html', $doc->documentElement->tagName); } + public function testFragment() { + $html = "<div>test</div>"; + $doc = $this->parseFragment($html); + + $this->assertInstanceOf('\DOMDocumentFragment', $doc); + $this->assertTrue($doc->hasChildNodes()); + $this->assertEquals('div', $doc->childNodes->item(0)->tagName); + } + public function testElements() { $html = "<!DOCTYPE html><html><head><title></title></head><body></body></html>"; $doc = $this->parse($html); |