diff options
author | Asmir Mustafic <[email protected]> | 2016-08-19 10:27:17 +0200 |
---|---|---|
committer | Asmir Mustafic <[email protected]> | 2016-08-19 10:30:18 +0200 |
commit | 24257c8ed81e52fdd773c501d6234d93581f82dd (patch) | |
tree | 02199fbb1a560824819f1faf3b4ffa33b22f53d8 /test/HTML5/Serializer | |
parent | 4c3a92351e499a907ff6073c5b3066dde44df555 (diff) |
Alternative implementation of https://github.com/Masterminds/html5-php/pull/115
Diffstat (limited to 'test/HTML5/Serializer')
-rw-r--r-- | test/HTML5/Serializer/OutputRulesTest.php | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index 1f717be..72253d3 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -627,34 +627,24 @@ class OutputRulesTest extends \Masterminds\HTML5\Tests\TestCase { $dom = $this->html5->loadHTML( '<!doctype html> - <html lang="en" id="base"> - <body> - <p>Foo</p> - <style id="test"> - blah - </style> - <p>Baz</p> - </body> - </html>'); - - // modify the content of the TEXT_RAW element - $badNode = $dom->createElement("p"); - $badNode->appendChild($dom->createTextNode("Bar")); - - $styleElement = $dom->getElementById("test"); +<html lang="en" id="base"> + <body> + <script id="template" type="x-tmpl-mustache"> + <h1>Hello!</h1> + </script> + </body> +</html>'); + + $badNode = $dom->createElement("p", "Bar"); + + // modify the content of the TEXT_RAW element: <script id="template"> appending dom nodes + $styleElement = $dom->getElementById("template"); $styleElement->appendChild($badNode); - // create the OutputRules instance and run the tests - $stream = fopen('php://temp', 'w'); - $r = new OutputRules($stream, $this->html5->getOptions()); - $t = new Traverser($dom, $stream, $r, $this->html5->getOptions()); - - $r->element($dom->getElementById('base')); - $contents = stream_get_contents($stream, - 1, 0); - - $this->assertRegExp('|<p>Foo</p>|', $contents); - $this->assertNotRegExp('|<p>Bar</p>|', $contents); - $this->assertRegExp('|<p>Baz</p>|', $contents); + $contents = $this->html5->saveHTML($dom); + $this->assertTrue(strpos($contents, '<script id="template" type="x-tmpl-mustache"> + <h1>Hello!</h1> + <p>Bar</p></script>')!==false); } } |