From 03094ac9606d90265d8b6bcce908f739e9798e46 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Tue, 17 Jun 2014 16:00:24 +0200 Subject: Serialization rules for boolean attributes --- test/HTML5/Serializer/OutputRulesTest.php | 37 +++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'test/HTML5/Serializer/OutputRulesTest.php') diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index a54a754..9f1c573 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -438,12 +438,45 @@ class OutputRulesTest extends \Masterminds\HTML5\Tests\TestCase $this->assertEquals($expected, $m->invoke($o, $test, $isAttribute)); } + public function booleanAttributes() + { + return array( + array(''), + array(''), + array(''), + array(''), + array(''), + array(''), + array(''), + ); + } + /** + * @dataProvider booleanAttributes + */ + public function testBooleanAttrs($html) + { + $dom = $this->html5->loadHTML(''.$html.''); + + $stream = fopen('php://temp', 'w'); + $r = new OutputRules($stream, $this->html5->getOptions()); + $t = new Traverser($dom, $stream, $r, $this->html5->getOptions()); + + $node = $dom->getElementsByTagName('body')->item(0)->firstChild; + + $m = $this->getProtectedMethod('attrs'); + $m->invoke($r, $node); + + $content = stream_get_contents($stream, - 1, 0); + $this->assertContains($content, $html); + + } + public function testAttrs() { $dom = $this->html5->loadHTML(' -
foo bar baz
+
foo bar baz
'); @@ -457,7 +490,7 @@ class OutputRulesTest extends \Masterminds\HTML5\Tests\TestCase $m->invoke($r, $list->item(0)); $content = stream_get_contents($stream, - 1, 0); - $this->assertEquals(' id="foo" class="bar baz" disabled', $content); + $this->assertEquals(' id="foo" class="bar baz"', $content); } public function testSvg() -- cgit v1.2.3 From 10e596d431786db01b67ca274a60fb0421791055 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Mon, 30 Jun 2014 13:05:18 +0200 Subject: Easier implementation. Instead looking for boolean attributes, we can serach for non-boolean attrs. Is a more compatible approach, with its own drawbacks. --- test/HTML5/Serializer/OutputRulesTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test/HTML5/Serializer/OutputRulesTest.php') diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index 9f1c573..62238c3 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -441,12 +441,13 @@ class OutputRulesTest extends \Masterminds\HTML5\Tests\TestCase public function booleanAttributes() { return array( + array(''), + array(''), array(''), array(''), array(''), array(''), - array(''), - array(''), + array('
foo
'), array(''), ); } -- cgit v1.2.3