diff options
author | Asmir Mustafic <[email protected]> | 2014-07-22 09:29:00 +0200 |
---|---|---|
committer | Asmir Mustafic <[email protected]> | 2014-07-22 09:29:00 +0200 |
commit | 425fd50d88fcf529b31c2db09f1882ea778b7231 (patch) | |
tree | e42feaf88ca66d801751efc2b2c801c9bd812d1d /test/HTML5/Serializer/OutputRulesTest.php | |
parent | ebae60bed13e0df3da4c13f7540052d40dee847f (diff) | |
parent | 10e596d431786db01b67ca274a60fb0421791055 (diff) |
Merge remote-tracking branch 'goetas/bolean-attr'
Diffstat (limited to 'test/HTML5/Serializer/OutputRulesTest.php')
-rw-r--r-- | test/HTML5/Serializer/OutputRulesTest.php | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index 558e6b0..e89d723 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -439,12 +439,46 @@ class OutputRulesTest extends \Masterminds\HTML5\Tests\TestCase $this->assertEquals($expected, $m->invoke($o, $test, $isAttribute)); } + public function booleanAttributes() + { + return array( + array('<img alt="" ismap>'), + array('<img alt="">'), + array('<input type="radio" readonly>'), + array('<input type="radio" checked disabled>'), + array('<input type="checkbox" checked disabled>'), + array('<select disabled></select>'), + array('<div ng-app>foo</div>'), + array('<script defer></script>'), + ); + } + /** + * @dataProvider booleanAttributes + */ + public function testBooleanAttrs($html) + { + $dom = $this->html5->loadHTML('<!doctype html><html lang="en"><body>'.$html.'</body></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('<!doctype html> <html lang="en"> <body> - <div id="foo" class="bar baz" disabled>foo bar baz</div> + <div id="foo" class="bar baz">foo bar baz</div> </body> </html>'); @@ -458,7 +492,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() |