public function OutputRulesTest::testText in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/masterminds/html5/test/HTML5/Serializer/OutputRulesTest.php \Masterminds\HTML5\Tests\Serializer\OutputRulesTest::testText()
File
- vendor/
masterminds/ html5/ test/ HTML5/ Serializer/ OutputRulesTest.php, line 326
Class
Namespace
Masterminds\HTML5\Tests\SerializerCode
public function testText() {
$dom = $this->html5
->loadHTML('<!doctype html>
<html lang="en">
<head>
<script>baz();</script>
</head>
</html>');
$stream = fopen('php://temp', 'w');
$r = new OutputRules($stream, $this->html5
->getOptions());
$t = new Traverser($dom, $stream, $r, $this->html5
->getOptions());
$list = $dom
->getElementsByTagName('script');
$r
->text($list
->item(0)->childNodes
->item(0));
$this
->assertEquals('baz();', stream_get_contents($stream, -1, 0));
$dom = $this->html5
->loadHTML('<!doctype html>
<html lang="en">
<head id="foo"></head>
</html>');
$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());
$r
->text($foo->firstChild);
$this
->assertEquals('<script>alert("hi");</script>', stream_get_contents($stream, -1, 0));
}