You are here

public function DOMTreeBuilderTest::testAttributes in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/masterminds/html5/test/HTML5/Parser/DOMTreeBuilderTest.php \Masterminds\HTML5\Tests\Parser\DOMTreeBuilderTest::testAttributes()

File

vendor/masterminds/html5/test/HTML5/Parser/DOMTreeBuilderTest.php, line 260
Test the Tree Builder.

Class

DOMTreeBuilderTest
These tests are functional, not necessarily unit tests.

Namespace

Masterminds\HTML5\Tests\Parser

Code

public function testAttributes() {
  $html = "<!DOCTYPE html>\n      <html>\n      <head><title></title></head>\n      <body id='a' class='b c'></body>\n      </html>";
  $doc = $this
    ->parse($html);
  $root = $doc->documentElement;
  $body = $root
    ->GetElementsByTagName('body')
    ->item(0);
  $this
    ->assertEquals('body', $body->tagName);
  $this
    ->assertTrue($body
    ->hasAttributes());
  $this
    ->assertEquals('a', $body
    ->getAttribute('id'));
  $this
    ->assertEquals('b c', $body
    ->getAttribute('class'));
  $body2 = $doc
    ->getElementById('a');
  $this
    ->assertEquals('body', $body2->tagName);
  $this
    ->assertEquals('a', $body2
    ->getAttribute('id'));
}