From be7f40d38223cf6cf4aa1ce180de9e3bd36672c5 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 24 Apr 2013 22:54:20 -0500 Subject: MAJOR changes to the DOMTreeBuilder. This now supports most of the tree building. It has limited support for insertion modes, as well as some syntax correction. --- test/HTML5/Parser/DOMTreeBuilderTest.php | 37 +++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'test/HTML5') diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php index a901238..562b9d5 100644 --- a/test/HTML5/Parser/DOMTreeBuilderTest.php +++ b/test/HTML5/Parser/DOMTreeBuilderTest.php @@ -76,8 +76,34 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { $this->assertEquals('a', $body2->getAttribute('id')); } + public function testMissingHtmlTag() { + $html = "test"; + $doc = $this->parse($html); + + $this->assertEquals('html', $doc->documentElement->tagName); + $this->assertEquals('title', $doc->documentElement->childNodes->item(0)->tagName); + } + public function testComment() { - $this->markTestIncomplete("Incomplete."); + $html = ''; + + $doc = $this->parse($html); + + $comment = $doc->documentElement->childNodes->item(0); + $this->assertEquals(XML_COMMENT_NODE, $comment->nodeType); + $this->assertEquals("Hello World.", $comment->data); + + + $html = ''; + $doc = $this->parse($html); + + $comment = $doc->childNodes->item(1); + $this->assertEquals(XML_COMMENT_NODE, $comment->nodeType); + $this->assertEquals("Hello World.", $comment->data); + + $comment = $doc->childNodes->item(2); + $this->assertEquals(XML_ELEMENT_NODE, $comment->nodeType); + $this->assertEquals("html", $comment->tagName); } public function testCDATA() { @@ -95,4 +121,13 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { public function testProcessingInstruction() { $this->markTestIncomplete("Incomplete."); } + + public function testAutocloseP() { + $html = "

"; + $doc = $this->parse($html); + + $p = $doc->getElementsByTagName('p')->item(0); + $this->assertEquals(0, $p->childNodes->length); + $this->assertEquals('figure', $p->nextSibling->tagName); + } } -- cgit v1.2.3