You are here

public function Html5Test::testSvg in Zircon Profile 8

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

File

vendor/masterminds/html5/test/HTML5/Html5Test.php, line 176

Class

Html5Test

Namespace

Masterminds\HTML5\Tests

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" />
            <text font-family="Verdana" font-size="32">
              <textPath xlink:href="#Foo">
                Test Text.
              </textPath>
            </text>
          </svg>
        </body>
      </html>');
  $this
    ->assertEmpty($this->html5
    ->getErrors());

  // Test a mixed case attribute.
  $list = $dom
    ->getElementsByTagName('svg');
  $this
    ->assertNotEmpty($list->length);
  $svg = $list
    ->item(0);
  $this
    ->assertEquals("0 0 3 2", $svg
    ->getAttribute('viewBox'));
  $this
    ->assertFalse($svg
    ->hasAttribute('viewbox'));

  // Test a mixed case tag.
  // Note: getElementsByTagName is not case sensetitive.
  $list = $dom
    ->getElementsByTagName('textPath');
  $this
    ->assertNotEmpty($list->length);
  $textPath = $list
    ->item(0);
  $this
    ->assertEquals('textPath', $textPath->tagName);
  $this
    ->assertNotEquals('textpath', $textPath->tagName);
  $html = $this->html5
    ->saveHTML($dom);
  $this
    ->assertRegExp('|<svg width="150" height="100" viewBox="0 0 3 2">|', $html);
  $this
    ->assertRegExp('|<rect width="1" height="2" x="0" fill="#008d46" />|', $html);
}