You are here

public function DOMTreeBuilderTest::testProcessingInstruction 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::testProcessingInstruction()

File

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

Class

DOMTreeBuilderTest
These tests are functional, not necessarily unit tests.

Namespace

Masterminds\HTML5\Tests\Parser

Code

public function testProcessingInstruction() {

  // Test the simple case, which is where PIs are inserted into the DOM.
  $doc = $this
    ->parse('<!DOCTYPE html><html><?foo bar?>');
  $this
    ->assertEquals(1, $doc->documentElement->childNodes->length);
  $pi = $doc->documentElement->firstChild;
  $this
    ->assertInstanceOf('\\DOMProcessingInstruction', $pi);
  $this
    ->assertEquals('foo', $pi->nodeName);
  $this
    ->assertEquals('bar', $pi->data);

  // Leading xml PIs should be ignored.
  $doc = $this
    ->parse('<?xml version="1.0"?><!DOCTYPE html><html><head></head></html>');
  $this
    ->assertEquals(2, $doc->childNodes->length);
  $this
    ->assertInstanceOf('\\DOMDocumentType', $doc->childNodes
    ->item(0));
  $this
    ->assertInstanceOf('\\DOMElement', $doc->childNodes
    ->item(1));
}