diff options
author | Matt Farina <[email protected]> | 2013-07-01 10:01:45 -0400 |
---|---|---|
committer | Matt Farina <[email protected]> | 2013-07-01 10:01:45 -0400 |
commit | a5361e80a3de563e4ffc555088ccc6c542e09e43 (patch) | |
tree | f4b60bd2af9c9e43401a39fc37c19401610bf5e0 | |
parent | d554fd0d726387ea622e6af0c84ae9a21ca3951f (diff) |
Added more mathml tests.
-rw-r--r-- | src/HTML5/Serializer/Traverser.php | 2 | ||||
-rw-r--r-- | test/HTML5/Parser/DOMTreeBuilderTest.php | 51 |
2 files changed, 46 insertions, 7 deletions
diff --git a/src/HTML5/Serializer/Traverser.php b/src/HTML5/Serializer/Traverser.php index 7f63e89..d7d2e5b 100644 --- a/src/HTML5/Serializer/Traverser.php +++ b/src/HTML5/Serializer/Traverser.php @@ -15,7 +15,7 @@ class Traverser { /** Namespaces that should be treated as "local" to HTML5. */ static $local_ns = array( 'http://www.w3.org/1999/xhtml' => 'html', - 'http://www.w3.org/1998/Math/MathML' => 'mathml', + 'http://www.w3.org/1998/Math/MathML' => 'math', 'http://www.w3.org/2000/svg' => 'svg', ); diff --git a/test/HTML5/Parser/DOMTreeBuilderTest.php b/test/HTML5/Parser/DOMTreeBuilderTest.php index aec7499..b6ee977 100644 --- a/test/HTML5/Parser/DOMTreeBuilderTest.php +++ b/test/HTML5/Parser/DOMTreeBuilderTest.php @@ -123,6 +123,27 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { $this->assertEquals(1, $ac->length); } + public function testMathMLAttribute() { + $html = '<!doctype html> + <html lang="en"> + <body> + <math> + <mi>x</mi> + <csymbol definitionurl="http://www.example.com/mathops/multiops.html#plusminus"> + <mo>±</mo> + </csymbol> + <mi>y</mi> + </math> + </body> + </html>'; + + $doc = $this->parse($html); + $root = $doc->documentElement; + + $csymbol = $root->getElementsByTagName('csymbol')->item(0); + $this->assertTrue($csymbol->hasAttribute('definitionURL')); + } + public function testMissingHtmlTag() { $html = "<!DOCTYPE html><title>test</title>"; $doc = $this->parse($html); @@ -154,10 +175,10 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { } public function testCDATA() { - $html = "<!DOCTYPE html><html><mathml><![CDATA[test]]></mathml></html>"; + $html = "<!DOCTYPE html><html><math><![CDATA[test]]></math></html>"; $doc = $this->parse($html); - $wrapper = $doc->getElementsByTagName('mathml')->item(0); + $wrapper = $doc->getElementsByTagName('math')->item(0); $this->assertEquals(1, $wrapper->childNodes->length); $cdata = $wrapper->childNodes->item(0); $this->assertEquals(XML_CDATA_SECTION_NODE, $cdata->nodeType); @@ -165,10 +186,10 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { } public function testText() { - $html = "<!DOCTYPE html><html><head></head><body><mathml>test</mathml></body></html>"; + $html = "<!DOCTYPE html><html><head></head><body><math>test</math></body></html>"; $doc = $this->parse($html); - $wrapper = $doc->getElementsByTagName('mathml')->item(0); + $wrapper = $doc->getElementsByTagName('math')->item(0); $this->assertEquals(1, $wrapper->childNodes->length); $data = $wrapper->childNodes->item(0); $this->assertEquals(XML_TEXT_NODE, $data->nodeType); @@ -176,7 +197,7 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { } public function testParseErrors() { - $html = "<!DOCTYPE html><html><mathml><![CDATA[test"; + $html = "<!DOCTYPE html><html><math><![CDATA[test"; $doc = $this->parse($html); // We're JUST testing that we can access errors. Actual testing of @@ -216,7 +237,25 @@ class DOMTreeBuilderTest extends \HTML5\Tests\TestCase { } public function testMathML() { - $this->markTestIncomplete("Incomplete."); + $html = '<!doctype html> + <html lang="en"> + <body> + <math xmlns="http://www.w3.org/1998/Math/MathML"> + <mi>x</mi> + <csymbol definitionurl="http://www.example.com/mathops/multiops.html#plusminus"> + <mo>±</mo> + </csymbol> + <mi>y</mi> + </math> + </body> + </html>'; + + $doc = $this->parse($html); + $math = $doc->getElementsByTagName('math')->item(0); + $this->assertEquals('math', $math->tagName); + $this->assertEquals('math', $math->nodeName); + $this->assertEquals('math', $math->localName); + $this->assertEmpty($math->namespaceURI); } public function testSVG() { |