You are here

public function OutputRulesTest::testSvg 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::testSvg()

File

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

Class

OutputRulesTest

Namespace

Masterminds\HTML5\Tests\Serializer

Code

public function testSvg() {
  $dom = $this->html5
    ->loadHTML('<!doctype html>
    <html lang="en">
      <body>
        <div id="foo" class="bar baz">foo bar baz</div>
        <svg width="150" height="100" viewBox="0 0 3 2">
          <rect width="1" height="2" x="0" fill="#008d46" />
          <rect width="1" height="2" x="1" fill="#ffffff" />
          <rect width="1" height="2" x="2" fill="#d2232c" />
          <rect id="Bar" x="300" y="100" width="300" height="100" fill="rgb(255,255,0)">
            <animate attributeName="x" attributeType="XML" begin="0s" dur="9s" fill="freeze" from="300" to="0" />
          </rect>
        </svg>
      </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('svg');
  $r
    ->element($list
    ->item(0));
  $contents = stream_get_contents($stream, -1, 0);
  $this
    ->assertRegExp('|<svg width="150" height="100" viewBox="0 0 3 2">|', $contents);
  $this
    ->assertRegExp('|<rect width="1" height="2" x="0" fill="#008d46" />|', $contents);
  $this
    ->assertRegExp('|<rect id="Bar" x="300" y="100" width="300" height="100" fill="rgb\\(255,255,0\\)">|', $contents);
}