summaryrefslogtreecommitdiff
path: root/test/HTML5/Parser/DOMTreeBuilderTest.php
diff options
context:
space:
mode:
authorMatt Farina <[email protected]>2013-11-06 07:35:21 -0500
committerMatt Farina <[email protected]>2013-11-06 07:35:21 -0500
commit51afaed4bad68a56c1719b89156f1fd80bdc7e44 (patch)
tree9a87914b049161a702a81cb714af0e8632fbebd9 /test/HTML5/Parser/DOMTreeBuilderTest.php
parent5734589d119502ddb81211fb6c3b55e28bc5eed3 (diff)
Improved test coverage. This caused a bug in processor instructions to appear. Fix them so they actually work now.
Diffstat (limited to 'test/HTML5/Parser/DOMTreeBuilderTest.php')
-rw-r--r--test/HTML5/Parser/DOMTreeBuilderTest.php39
1 files changed, 39 insertions, 0 deletions
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 = '<!DOCTYPE html><html><head><noscript>No JS</noscript></head></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 = '<!DOCTYPE html><html><?foo bar ?></html>';
+
+ $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++;
+ }
}