summaryrefslogtreecommitdiff
path: root/test/HTML5
diff options
context:
space:
mode:
Diffstat (limited to 'test/HTML5')
-rw-r--r--test/HTML5/Parser/DOMTreeBuilderTest.php16
-rw-r--r--test/HTML5/Serializer/OutputRulesTest.php6
2 files changed, 11 insertions, 11 deletions
diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php
index 0046d88..2745395 100644
--- a/test/HTML5/Parser/DOMTreeBuilderTest.php
+++ b/test/HTML5/Parser/DOMTreeBuilderTest.php
@@ -15,7 +15,7 @@ use Masterminds\HTML5\Parser\DOMTreeBuilder;
*/
class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase
{
-
+ protected $errors = array();
/**
* Convenience function for parsing.
*/
@@ -27,6 +27,7 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase
$parser = new Tokenizer($scanner, $treeBuilder);
$parser->parse();
+ $this->errors = $treeBuilder->getErrors();
return $treeBuilder->document();
}
@@ -42,6 +43,7 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase
$parser = new Tokenizer($scanner, $treeBuilder);
$parser->parse();
+ $this->errors = $treeBuilder->getErrors();
return $treeBuilder->fragment();
}
@@ -153,12 +155,10 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase
<c id="bar2" xmlns="bar2"></c>
<div id="div"></div>
<d id="bar3"></d>
-
</body>
</html>', array(
'xmlNamespaces' => true
));
-
$div = $dom->getElementById('div');
$this->assertEquals('http://www.w3.org/1999/xhtml', $div->namespaceURI);
@@ -307,7 +307,7 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase
$html = "<!DOCTYPE html><html>
Foo<head></head><body></body></html>";
$doc = $this->parse($html);
- $this->assertEquals('Line 0, Col 0: Unexpected text. Ignoring: Foo', $doc->errors[0]);
+ $this->assertEquals('Line 0, Col 0: Unexpected text. Ignoring: Foo', $this->errors[0]);
$headElement = $doc->documentElement->firstChild;
$this->assertEquals('head', $headElement->tagName);
}
@@ -319,8 +319,8 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase
// We're JUST testing that we can access errors. Actual testing of
// error messages happen in the Tokenizer's tests.
- $this->assertGreaterThan(0, count($doc->errors));
- $this->assertTrue(is_string($doc->errors[0]));
+ $this->assertGreaterThan(0, count($this->errors));
+ $this->assertTrue(is_string($this->errors[0]));
}
public function testProcessingInstruction()
@@ -419,7 +419,7 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase
{
$html = '<!DOCTYPE html><html><head><noscript>No JS</noscript></head></html>';
$doc = $this->parse($html);
- $this->assertEmpty($doc->errors);
+ $this->assertEmpty($this->errors);
$noscript = $doc->getElementsByTagName('noscript')->item(0);
$this->assertEquals('noscript', $noscript->tagName);
}
@@ -433,7 +433,7 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase
$doc = $this->parse($html);
$span = $doc->getElementById('test');
- $this->assertEmpty($doc->errors);
+ $this->assertEmpty($this->errors);
$this->assertEquals('span', $span->tagName);
$this->assertEquals('Test', $span->textContent);
diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php
index a54a754..f12acbb 100644
--- a/test/HTML5/Serializer/OutputRulesTest.php
+++ b/test/HTML5/Serializer/OutputRulesTest.php
@@ -330,14 +330,14 @@ class OutputRulesTest extends \Masterminds\HTML5\Tests\TestCase
<html lang="en">
<head id="foo"></head>
</html>');
- $dom->getElementById('foo')->appendChild(new \DOMText('<script>alert("hi");</script>'));
+ $foo = $dom->getElementById('foo');
+ $foo->appendChild(new \DOMText('<script>alert("hi");</script>'));
$stream = fopen('php://temp', 'w');
$r = new OutputRules($stream, $this->html5->getOptions());
$t = new Traverser($dom, $stream, $r, $this->html5->getOptions());
- $item = $dom->getElementById('foo');
- $r->text($item->firstChild);
+ $r->text($foo->firstChild);
$this->assertEquals('&lt;script&gt;alert("hi");&lt;/script&gt;', stream_get_contents($stream, - 1, 0));
}