public function DOMTreeBuilderTest::testText in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/masterminds/html5/test/HTML5/Parser/DOMTreeBuilderTest.php \Masterminds\HTML5\Tests\Parser\DOMTreeBuilderTest::testText()
File
- vendor/
masterminds/ html5/ test/ HTML5/ Parser/ DOMTreeBuilderTest.php, line 368 - Test the Tree Builder.
Class
- DOMTreeBuilderTest
- These tests are functional, not necessarily unit tests.
Namespace
Masterminds\HTML5\Tests\ParserCode
public function testText() {
$html = "<!DOCTYPE html><html><head></head><body><math>test</math></body></html>";
$doc = $this
->parse($html);
$wrapper = $doc
->getElementsByTagName('math')
->item(0);
$this
->assertEquals(1, $wrapper->childNodes->length);
$data = $wrapper->childNodes
->item(0);
$this
->assertEquals(XML_TEXT_NODE, $data->nodeType);
$this
->assertEquals('test', $data->data);
// The DomTreeBuilder has special handling for text when in before head mode.
$html = "<!DOCTYPE html><html>\n Foo<head></head><body></body></html>";
$doc = $this
->parse($html);
$this
->assertEquals('Line 0, Col 0: Unexpected text. Ignoring: Foo', $this->errors[0]);
$headElement = $doc->documentElement->firstChild;
$this
->assertEquals('head', $headElement->tagName);
}