diff options
author | Asmir Mustafic <[email protected]> | 2014-09-23 06:49:02 -0300 |
---|---|---|
committer | Asmir Mustafic <[email protected]> | 2014-09-23 06:49:02 -0300 |
commit | e1e579a69254e8e20d6270b5c13c4475f8461438 (patch) | |
tree | 116dc4c20aa7081321727edf9439f9d876f9f7f4 /test/HTML5/Parser/TreeBuildingRulesTest.php | |
parent | ef464694f9e0aea42f1949bcf1e787859e02d0b3 (diff) |
Fragments with rules
Diffstat (limited to 'test/HTML5/Parser/TreeBuildingRulesTest.php')
-rw-r--r-- | test/HTML5/Parser/TreeBuildingRulesTest.php | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/test/HTML5/Parser/TreeBuildingRulesTest.php b/test/HTML5/Parser/TreeBuildingRulesTest.php index cb9b1e4..bff2530 100644 --- a/test/HTML5/Parser/TreeBuildingRulesTest.php +++ b/test/HTML5/Parser/TreeBuildingRulesTest.php @@ -25,14 +25,36 @@ class TreeBuildingRulesTest extends \Masterminds\HTML5\Tests\TestCase protected function parse($string) { $treeBuilder = new DOMTreeBuilder(); - $input = new StringInputStream($string); - $scanner = new Scanner($input); + $scanner = new Scanner(new StringInputStream($string)); $parser = new Tokenizer($scanner, $treeBuilder); $parser->parse(); - return $treeBuilder->document(); } + /** + * Convenience function for parsing fragments. + */ + protected function parseFragment($string) + { + $events = new DOMTreeBuilder(true); + $scanner = new Scanner(new StringInputStream($string)); + $parser = new Tokenizer($scanner, $events); + + $parser->parse(); + return $events->fragment(); + } + + public function testTDFragment() + { + + $frag = $this->parseFragment("<td>This is a test of the HTML5 parser</td>"); + + $td = $frag->childNodes->item(0); + + $this->assertEquals(1, $frag->childNodes->length); + $this->assertEquals('td', $td->tagName); + $this->assertEquals('This is a test of the HTML5 parser', $td->nodeValue); + } public function testHasRules() { |