From fe3d7b815756b6f9ec3bad7c9bfe400b6ea11222 Mon Sep 17 00:00:00 2001 From: Technosophos Date: Wed, 24 Apr 2013 17:33:08 -0500 Subject: Added attribute handling. --- test/HTML5/Parser/DOMTreeBuilderTest.php | 67 +++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) (limited to 'test/HTML5/Parser') diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php index 963000c..a901238 100644 --- a/test/HTML5/Parser/DOMTreeBuilderTest.php +++ b/test/HTML5/Parser/DOMTreeBuilderTest.php @@ -1,12 +1,17 @@ assertInstanceOf('\DOMDocument', $doc); $this->assertEquals('html', $doc->documentElement->tagName); } + + public function testElements() { + $html = ""; + $doc = $this->parse($html); + $root = $doc->documentElement; + + $this->assertEquals('html', $root->tagName); + $this->assertEquals('html', $root->localName); + $this->assertEquals('html', $root->nodeName); + + $this->assertEquals(2, $root->childNodes->length); + $kids = $root->childNodes; + + $this->assertEquals('head', $kids->item(0)->tagName); + $this->assertEquals('body', $kids->item(1)->tagName); + + $head = $kids->item(0); + $this->assertEquals(1, $head->childNodes->length); + $this->assertEquals('title', $head->childNodes->item(0)->tagName); + } + + public function testAttributes() { + $html = " + + + + "; + $doc = $this->parse($html); + $root = $doc->documentElement; + + $body = $root->GetElementsByTagName('body')->item(0); + $this->assertEquals('body', $body->tagName); + $this->assertTrue($body->hasAttributes()); + $this->assertEquals('a', $body->getAttribute('id')); + $this->assertEquals('b c', $body->getAttribute('class')); + + $body2 = $doc->getElementById('a'); + $this->assertEquals('body', $body2->tagName); + $this->assertEquals('a', $body2->getAttribute('id')); + } + + public function testComment() { + $this->markTestIncomplete("Incomplete."); + } + + public function testCDATA() { + $this->markTestIncomplete("Incomplete."); + } + + public function testText() { + $this->markTestIncomplete("Incomplete."); + } + + public function testParseErrors() { + $this->markTestIncomplete("Incomplete."); + } + + public function testProcessingInstruction() { + $this->markTestIncomplete("Incomplete."); + } } -- cgit v1.2.3