You are here

public function Html5Test::testLoadOptions 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::testLoadOptions()

File

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

Class

Html5Test

Namespace

Masterminds\HTML5\Tests

Code

public function testLoadOptions() {

  // doc
  $dom = $this->html5
    ->loadHTML($this
    ->wrap('<t:tag/>'), array(
    'implicitNamespaces' => array(
      't' => 'http://example.com',
    ),
    "xmlNamespaces" => true,
  ));
  $this
    ->assertInstanceOf('\\DOMDocument', $dom);
  $this
    ->assertEmpty($this->html5
    ->getErrors());
  $this
    ->assertFalse($this->html5
    ->hasErrors());
  $xpath = new \DOMXPath($dom);
  $xpath
    ->registerNamespace("t", "http://example.com");
  $this
    ->assertEquals(1, $xpath
    ->query("//t:tag")->length);

  // doc fragment
  $frag = $this->html5
    ->loadHTMLFragment('<t:tag/>', array(
    'implicitNamespaces' => array(
      't' => 'http://example.com',
    ),
    "xmlNamespaces" => true,
  ));
  $this
    ->assertInstanceOf('\\DOMDocumentFragment', $frag);
  $this
    ->assertEmpty($this->html5
    ->getErrors());
  $this
    ->assertFalse($this->html5
    ->hasErrors());
  $frag->ownerDocument
    ->appendChild($frag);
  $xpath = new \DOMXPath($frag->ownerDocument);
  $xpath
    ->registerNamespace("t", "http://example.com");
  $this
    ->assertEquals(1, $xpath
    ->query("//t:tag", $frag)->length);
}