You are here

public function OutputRulesTest::testComment in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/masterminds/html5/test/HTML5/Serializer/OutputRulesTest.php \Masterminds\HTML5\Tests\Serializer\OutputRulesTest::testComment()

File

vendor/masterminds/html5/test/HTML5/Serializer/OutputRulesTest.php, line 289

Class

OutputRulesTest

Namespace

Masterminds\HTML5\Tests\Serializer

Code

public function testComment() {
  $dom = $this->html5
    ->loadHTML('<!doctype html>
    <html lang="en">
      <body>
        <div><!-- foo --></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
    ->comment($list
    ->item(0)->childNodes
    ->item(0));
  $this
    ->assertEquals('<!-- foo -->', 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 \DOMComment('<!-- --> --> Foo -->'));
  $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
    ->comment($list
    ->item(0)->childNodes
    ->item(0));

  // Could not find more definitive guidelines on what this should be. Went with
  // what the HTML5 spec says and what \DOMDocument::saveXML() produces.
  $this
    ->assertEquals('<!--<!-- --> --> Foo -->-->', stream_get_contents($stream, -1, 0));
}