diff options
author | Matt Farina <[email protected]> | 2013-06-11 22:22:24 -0400 |
---|---|---|
committer | Matt Farina <[email protected]> | 2013-06-11 22:22:24 -0400 |
commit | 095e2df659c2636eeebfd87414da9264aca82c21 (patch) | |
tree | 8f74515ce5013c778655d9b082189c1c7ace3e7c /test/HTML5/Serializer | |
parent | c47852d4db90f8420510d780dd0c16411a68e8f3 (diff) |
Part of #4 and #7: Added normalization of element and attribute names to SVG and MathML output.
Diffstat (limited to 'test/HTML5/Serializer')
-rw-r--r-- | test/HTML5/Serializer/OutputRulesTest.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index 4e1ce92..768434c 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -76,6 +76,11 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { <html lang="en"> <body> <div id="foo" class="bar baz">foo bar baz</div> + <svg width="150" height="100" viewBox="0 0 3 2"> + <rect width="1" height="2" x="0" fill="#008d46" /> + <rect width="1" height="2" x="1" fill="#ffffff" /> + <rect width="1" height="2" x="2" fill="#d2232c" /> + </svg> </body> </html>'); @@ -88,6 +93,24 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { $this->assertEquals('<div id="foo" class="bar baz">foo bar baz</div>', stream_get_contents($stream, -1, 0)); } + function testOpenTag() { + $dom = \HTML5::loadHTML('<!doctype html> + <html lang="en"> + <body> + <div id="foo" class="bar baz">foo bar baz</div> + </body> + </html>'); + + $stream = fopen('php://temp', 'w'); + $t = new Traverser($dom, $stream, \HTML5::options()); + $o = new OutputRules($t, $stream, \HTML5::options()); + + $list = $dom->getElementsByTagName('div'); + $m = $this->getProtectedMethod('openTag'); + $m->invoke($o, $list->item(0)); + $this->assertEquals('<div id="foo" class="bar baz">', stream_get_contents($stream, -1, 0)); + } + function testCData() { $dom = \HTML5::loadHTML('<!doctype html> <html lang="en"> @@ -175,4 +198,26 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { $this->assertEquals('.+#', $m->invoke($o, '.+#')); } + function testSvg() { + $dom = \HTML5::loadHTML('<!doctype html> + <html lang="en"> + <body> + <div id="foo" class="bar baz">foo bar baz</div> + <svg width="150" height="100" viewBox="0 0 3 2"> + <rect width="1" height="2" x="0" fill="#008d46" /> + <rect width="1" height="2" x="1" fill="#ffffff" /> + <rect width="1" height="2" x="2" fill="#d2232c" /> + </svg> + </body> + </html>'); + + $stream = fopen('php://temp', 'w'); + $t = new Traverser($dom, $stream, \HTML5::options()); + $o = new OutputRules($t, $stream, \HTML5::options()); + + $list = $dom->getElementsByTagName('svg'); + $o->element($list->item(0)); + $this->assertRegExp('|<svg width="150" height="100" viewBox="0 0 3 2">|', stream_get_contents($stream, -1, 0)); + } + }
\ No newline at end of file |