summaryrefslogtreecommitdiff
path: root/test/HTML5/Parser
diff options
context:
space:
mode:
authorTechnosophos <[email protected]>2013-04-24 17:33:08 -0500
committerTechnosophos <[email protected]>2013-04-24 17:33:08 -0500
commitfe3d7b815756b6f9ec3bad7c9bfe400b6ea11222 (patch)
treee3c1d3c638d3107a8002340f5f66abdc84a4eb40 /test/HTML5/Parser
parent102c57cc46df3b2dfcb435e9e51b8f733f11b741 (diff)
Added attribute handling.
Diffstat (limited to 'test/HTML5/Parser')
-rw-r--r--test/HTML5/Parser/DOMTreeBuilderTest.php67
1 files changed, 66 insertions, 1 deletions
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 @@
<?php
/**
* @file
- * Test the Scanner. This requires the InputStream tests are all good.
+ * Test the Tree Builder.
*/
namespace HTML5\Parser;
+use HTML5\Elements;
+
require_once __DIR__ . '/../TestCase.php';
+/**
+ * These tests are functional, not necessarily unit tests.
+ */
class DOMTreeBuilderTest extends \HTML5\Tests\TestCase {
/**
@@ -30,4 +35,64 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase {
$this->assertInstanceOf('\DOMDocument', $doc);
$this->assertEquals('html', $doc->documentElement->tagName);
}
+
+ public function testElements() {
+ $html = "<!DOCTYPE html><html><head><title></title></head><body></body></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 = "<!DOCTYPE html>
+ <html>
+ <head><title></title></head>
+ <body id='a' class='b c'></body>
+ </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.");
+ }
}