public function OutputRulesTest::testCData 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::testCData()
File
- vendor/
masterminds/ html5/ test/ HTML5/ Serializer/ OutputRulesTest.php, line 254
Class
Namespace
Masterminds\HTML5\Tests\SerializerCode
public function testCData() {
$dom = $this->html5
->loadHTML('<!doctype html>
<html lang="en">
<body>
<div><![CDATA[bar]]></div>
</body>
</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('div');
$r
->cdata($list
->item(0)->childNodes
->item(0));
$this
->assertEquals('<![CDATA[bar]]>', stream_get_contents($stream, -1, 0));
$dom = $this->html5
->loadHTML('<!doctype html>
<html lang="en">
<body>
<div id="foo"></div>
</body>
</html>');
$dom
->getElementById('foo')
->appendChild(new \DOMCdataSection("]]>Foo<[![CDATA test ]]>"));
$stream = fopen('php://temp', 'w');
$r = new OutputRules($stream, $this->html5
->getOptions());
$t = new Traverser($dom, $stream, $r, $this->html5
->getOptions());
$list = $dom
->getElementsByTagName('div');
$r
->cdata($list
->item(0)->childNodes
->item(0));
$this
->assertEquals('<![CDATA[]]]]><![CDATA[>Foo<[![CDATA test ]]]]><![CDATA[>]]>', stream_get_contents($stream, -1, 0));
}