From 254ca181261fb5326dc3c9688562f800f18dd2e7 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Wed, 12 Jun 2013 22:11:19 -0400 Subject: #4 and #7, Cleaned up the MathMl support and added a test. --- test/HTML5/Serializer/OutputRulesTest.php | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'test') diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index 768434c..70d3b7d 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -36,6 +36,13 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { return $method; } + function getTraverserProtectedProperty($name) { + $class = new \ReflectionClass('\HTML5\Serializer\Traverser'); + $property = $class->getProperty($name); + $property->setAccessible(true); + return $property; + } + function getOutputRules($options = array()) { $options = $options + \HTML5::options(); $stream = fopen('php://temp', 'w'); @@ -220,4 +227,31 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { $this->assertRegExp('||', stream_get_contents($stream, -1, 0)); } + function testMath() { + $dom = \HTML5::loadHTML(' + + +
foo bar baz
+ + x + + ± + + y + + + '); + + $stream = fopen('php://temp', 'w'); + $t = new Traverser($dom, $stream, \HTML5::options()); + $p = $this->getTraverserProtectedProperty('rules'); + $o = $p->getValue($t); + + $list = $dom->getElementsByTagName('math'); + $o->element($list->item(0)); + $content = stream_get_contents($stream, -1, 0); + $this->assertRegExp('||', $content); + $this->assertRegExp('||', $content); + } + } \ No newline at end of file -- cgit v1.2.3