You are here

public function DOMTreeBuilderTest::testElements in Zircon Profile 8

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

File

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

Class

DOMTreeBuilderTest
These tests are functional, not necessarily unit tests.

Namespace

Masterminds\HTML5\Tests\Parser

Code

public function testElements() {
  $html = "<!DOCTYPE html><html><head><title></title></head><body></body></html>";
  $doc = $this
    ->parse($html);
  $root = $doc->documentElement;
  $this
    ->assertEquals('html', $root->tagName);
  $this
    ->assertEquals('html', $root->localName);
  $this
    ->assertEquals('html', $root->nodeName);
  $this
    ->assertEquals(2, $root->childNodes->length);
  $kids = $root->childNodes;
  $this
    ->assertEquals('head', $kids
    ->item(0)->tagName);
  $this
    ->assertEquals('body', $kids
    ->item(1)->tagName);
  $head = $kids
    ->item(0);
  $this
    ->assertEquals(1, $head->childNodes->length);
  $this
    ->assertEquals('title', $head->childNodes
    ->item(0)->tagName);
}