From 51afaed4bad68a56c1719b89156f1fd80bdc7e44 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 6 Nov 2013 07:35:21 -0500 Subject: Improved test coverage. This caused a bug in processor instructions to appear. Fix them so they actually work now. --- test/HTML5/Parser/DOMTreeBuilderTest.php | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'test/HTML5/Parser/DOMTreeBuilderTest.php') diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php index adfc2c9..0adaed5 100644 --- a/test/HTML5/Parser/DOMTreeBuilderTest.php +++ b/test/HTML5/Parser/DOMTreeBuilderTest.php @@ -301,6 +301,14 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { $this->assertEquals('textPath', $textPath->tagName); } + public function testNoScript() { + $html = ''; + $doc = $this->parse($html); + $this->assertEmpty($doc->errors); + $noscript = $doc->getElementsByTagName('noscript')->item(0); + $this->assertEquals('noscript', $noscript->tagName); + } + /** * Regression for issue #13 */ @@ -314,4 +322,35 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { $this->assertEquals('span', $span->tagName); $this->assertEquals('Test', $span->textContent); } + + public function testInstructionProcessor() { + $string = ''; + + $treeBuilder = new DOMTreeBuilder(); + $is = new InstructionProcessorMock(); + $treeBuilder->setInstructionProcessor($is); + + $input = new StringInputStream($string); + $scanner = new Scanner($input); + $parser = new Tokenizer($scanner, $treeBuilder); + + $parser->parse(); + + $this->assertEquals(1, $is->count); + $this->assertEquals('foo', $is->name); + $this->assertEquals('bar ', $is->data); + } +} + +class InstructionProcessorMock implements \HTML5\InstructionProcessor { + + public $name = NULL; + public $data = NULL; + public $count = 0; + + public function process(\DOMElement $element, $name, $data) { + $this->name = $name; + $this->data = $data; + $this->count++; + } } -- cgit v1.2.3