From 46c4738fe893b8250da1531e093f3ccaee0769a9 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Tue, 6 Jan 2015 22:28:44 +0100 Subject: Added tests for "target_document" and "disable_html_ns" options --- test/HTML5/Parser/DOMTreeBuilderTest.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php index 5bba7cc..b2a2d39 100644 --- a/test/HTML5/Parser/DOMTreeBuilderTest.php +++ b/test/HTML5/Parser/DOMTreeBuilderTest.php @@ -55,6 +55,7 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase $this->assertInstanceOf('\DOMDocument', $doc); $this->assertEquals('html', $doc->documentElement->tagName); + $this->assertEquals('http://www.w3.org/1999/xhtml', $doc->documentElement->namespaceURI); } public function testStrangeCapitalization() @@ -78,6 +79,28 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase $this->assertEquals("foo", $xpath->query( "//x:script" )->item( 0 )->nodeValue); } + public function testDocumentWithDisabledNamespaces() + { + $html = ""; + $doc = $this->parse($html, array('disable_html_ns' => true)); + + $this->assertInstanceOf('\DOMDocument', $doc); + $this->assertEquals('html', $doc->documentElement->tagName); + $this->assertNull($doc->documentElement->namespaceURI); + } + + public function testDocumentWithATargetDocument() + { + $targetDom = new \DOMDocument(); + + $html = ""; + $doc = $this->parse($html, array('target_document' => $targetDom)); + + $this->assertInstanceOf('\DOMDocument', $doc); + $this->assertSame($doc, $targetDom); + $this->assertEquals('html', $doc->documentElement->tagName); + } + public function testDocumentFakeAttrAbsence() { $html = "foo"; @@ -85,7 +108,6 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase $xp = new \DOMXPath($doc); $this->assertEquals(0, $xp->query("//@html5-php-fake-id-attribute")->length); - } public function testFragment() -- cgit v1.2.3