From dd4a88998609e7efa6203b2ee776aac6d9df9b1c Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Thu, 2 May 2013 10:18:46 -0500 Subject: Stubbing out a rules engine for tag special-casing. --- test/HTML5/Parser/TreeBuildingRulesTest.php | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/HTML5/Parser/TreeBuildingRulesTest.php (limited to 'test') diff --git a/test/HTML5/Parser/TreeBuildingRulesTest.php b/test/HTML5/Parser/TreeBuildingRulesTest.php new file mode 100644 index 0000000..3ca3cbb --- /dev/null +++ b/test/HTML5/Parser/TreeBuildingRulesTest.php @@ -0,0 +1,39 @@ +parse(); + + return $treeBuilder->document(); + } + + public function testHasRules() { + $doc = new \DOMDocument('1.0'); + $engine = new TreeBuildingRules($doc); + + $this->assertTrue($engine->hasRules('li')); + $this->assertFalse($engine->hasRules('imaginary')); + } + +} -- cgit v1.2.3 From 7b243b238c29e787686cb60fe418c1cd21a6dd58 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Thu, 2 May 2013 11:02:07 -0500 Subject: Rules for LI, DT, DD, RT, and RP. --- test/HTML5/Parser/TreeBuildingRulesTest.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test') diff --git a/test/HTML5/Parser/TreeBuildingRulesTest.php b/test/HTML5/Parser/TreeBuildingRulesTest.php index 3ca3cbb..fe02893 100644 --- a/test/HTML5/Parser/TreeBuildingRulesTest.php +++ b/test/HTML5/Parser/TreeBuildingRulesTest.php @@ -14,6 +14,8 @@ require_once __DIR__ . '/../TestCase.php'; */ class TreeBuildingRulesTest extends \HTML5\Tests\TestCase { + const HTML_STUB = 'test%s'; + /** * Convenience function for parsing. */ @@ -36,4 +38,28 @@ class TreeBuildingRulesTest extends \HTML5\Tests\TestCase { $this->assertFalse($engine->hasRules('imaginary')); } + public function testHandleLI() { + $html = sprintf(self::HTML_STUB, ''); + $doc = $this->parse($html); + + $list = $doc->getElementById('a'); + + $this->assertEquals(2, $list->childNodes->length); + foreach($list->childNodes as $ele) { + $this->assertEquals('li', $ele->tagName); + } + + } + + public function testHandleDT() { + $html = sprintf(self::HTML_STUB, '
Hello
Hi
'); + $doc = $this->parse($html); + + $list = $doc->getElementById('a'); + + $this->assertEquals(2, $list->childNodes->length); + $this->assertEquals('dt', $list->firstChild->tagName); + $this->assertEquals('dd', $list->lastChild->tagName); + } + } -- cgit v1.2.3