From 072da11763d0188e0dad12335c85f43fe6fcf9b2 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Tue, 8 Jul 2014 10:40:06 +0200 Subject: Removed xmlns workaround, using a different method, that supports XMLNS declarations --- test/HTML5/Parser/DOMTreeBuilderTest.php | 23 ++++++++++++++----- test/HTML5/Serializer/OutputRulesTest.php | 37 ++++++++++++++++--------------- 2 files changed, 36 insertions(+), 24 deletions(-) (limited to 'test') diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php index c1b19e5..5227c40 100644 --- a/test/HTML5/Parser/DOMTreeBuilderTest.php +++ b/test/HTML5/Parser/DOMTreeBuilderTest.php @@ -157,17 +157,22 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase $dom = $this->parse( ' - - + + - +
+ ', array( 'xmlNamespaces' => true )); + + + $this->assertEmpty($this->errors); + $div = $dom->getElementById('div'); $this->assertEquals('http://www.w3.org/1999/xhtml', $div->namespaceURI); @@ -175,22 +180,28 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase $this->assertEquals('http://www.w3.org/1999/xhtml', $body->namespaceURI); $bar1 = $dom->getElementById('bar1'); - $this->assertEquals('bar1', $bar1->namespaceURI); + $this->assertEquals('http://www.prefixed.com/bar1', $bar1->namespaceURI); $bar2 = $dom->getElementById('bar2'); - $this->assertEquals("bar2", $bar2->namespaceURI); + $this->assertEquals("http://www.prefixed.com/bar2", $bar2->namespaceURI); $bar3 = $dom->getElementById('bar3'); $this->assertEquals("http://www.w3.org/1999/xhtml", $bar3->namespaceURI); $bar4 = $dom->getElementById('bar4'); - $this->assertEquals("bar4", $bar4->namespaceURI); + $this->assertEquals("http://www.prefixed.com/bar4", $bar4->namespaceURI); $svg = $dom->getElementById('svg'); $this->assertEquals("http://www.w3.org/2000/svg", $svg->namespaceURI); $prefixed = $dom->getElementById('prefixed'); $this->assertEquals("http://www.prefixed.com", $prefixed->namespaceURI); + + $prefixed = $dom->getElementById('bar5'); + $this->assertEquals("http://www.prefixed.com/xn", $prefixed->namespaceURI); + + $prefixed = $dom->getElementById('bar5_x'); + $this->assertEquals("http://www.prefixed.com/bar5_x", $prefixed->namespaceURI); } public function testAttributes() diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index f12acbb..df33faa 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -119,21 +119,24 @@ class OutputRulesTest extends \Masterminds\HTML5\Tests\TestCase 'xmlNamespaces' => true )); - $source = ' - - - x - - xx - xx -
xx
- xx - -'; + $source = ' + + + + xy + + svg + +
+ + y + + '; $dom = $this->html5->loadHTML($source, array( 'xmlNamespaces' => true )); + $this->assertFalse($this->html5->hasErrors(), print_r($this->html5->getErrors(), 1)); $stream = fopen('php://temp', 'w'); $r = new OutputRules($stream, $this->html5->getOptions()); @@ -142,13 +145,11 @@ class OutputRulesTest extends \Masterminds\HTML5\Tests\TestCase $t->walk(); $rendered = stream_get_contents($stream, - 1, 0); - $this->assertEquals(str_replace(array( - "\n", - "\r" - ), "", $rendered), str_replace(array( - "\n", - "\r" - ), "", $source)); + $clear = function($s){ + return trim(preg_replace('/[\s]+/', " ", $s)); + }; + + $this->assertEquals($clear($source), $clear($rendered)); } public function testElementWithScript() -- cgit v1.2.3