From 209adc250df8f73f1989aad309934c5f9f886888 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Tue, 6 Jan 2015 22:04:33 +0100 Subject: Added $options to HTML loading methods --- test/HTML5/Html5Test.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/HTML5/Html5Test.php') diff --git a/test/HTML5/Html5Test.php b/test/HTML5/Html5Test.php index 0ab367c..a1a6c9c 100644 --- a/test/HTML5/Html5Test.php +++ b/test/HTML5/Html5Test.php @@ -28,6 +28,36 @@ class Html5Test extends TestCase return $out; } + public function testLoadOptions() + { + // doc + $dom = $this->html5->loadHTML($this->wrap(''), 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('', 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); + } + public function testErrors() { $dom = $this->html5->loadHTML(''); -- cgit v1.2.3