diff options
author | Matt Farina <[email protected]> | 2014-02-11 20:21:34 -0500 |
---|---|---|
committer | Matt Farina <[email protected]> | 2014-02-11 20:21:34 -0500 |
commit | e21281f7c1d289d9237a34a906f9fec8195640d1 (patch) | |
tree | 186df6952a489e06380172c19a5139a3fc754e91 /test/HTML5/Serializer/OutputRulesTest.php | |
parent | 001243d8915bfad8e84c71134dabcbb7a0307bd3 (diff) | |
parent | fe713d549d436b63e8367756f19cb456e60d2ff3 (diff) |
Merge pull request #25 from goetas/patch-2
Removed quote conversion to entity inside content
Diffstat (limited to 'test/HTML5/Serializer/OutputRulesTest.php')
-rw-r--r-- | test/HTML5/Serializer/OutputRulesTest.php | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index 0c85492..d04ebef 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -217,7 +217,7 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { $item = $dom->getElementById('foo'); $r->text($item->firstChild); - $this->assertEquals('<script>alert("hi");</script>', stream_get_contents($stream, -1, 0)); + $this->assertEquals('<script>alert("hi");</script>', stream_get_contents($stream, -1, 0)); } function testNl() { @@ -236,24 +236,33 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { $this->assertEquals('foo', stream_get_contents($s, -1, 0)); } - function testEnc() { + function getEncData(){ + return array( + array(false, '&\'<>"', '&\'<>"', '&'<>"'), + array(false, 'This + is. a < test', 'This + is. a < test', 'This + is. a < test'), + array(false, '.+#', '.+#', '.+#'), - // Test basic escaping of text. - $tests = array( - '&\'<>"' => '&'<>"', - 'This + is. a < test' => 'This + is. a < test', + array(true, '.+#\'', '.+#\'', '.+#''), + array(true, '&".<', '&".<', '&".<'), + array(true, '&\'<>"', '&\'<>"', '&'<>"'), + array(true, "\xc2\xa0\"'", ' "\'', ' "''), ); + } + + /** + * Test basic escaping of text. + * @dataProvider getEncData + */ + function testEnc($isAttribute, $test, $expected, $expectedEncoded) { list($o, $s) = $this->getOutputRules(); $m = $this->getProtectedMethod('enc'); - foreach ($tests as $test => $expected) { - $this->assertEquals($expected, $m->invoke($o, $test)); - } + + $this->assertEquals($expected, $m->invoke($o, $test, $isAttribute)); list($o, $s) = $this->getOutputRules(array('encode_entities' => TRUE)); $m = $this->getProtectedMethod('enc'); - - $this->assertEquals('.+#', $m->invoke($o, '.+#')); + $this->assertEquals($expectedEncoded, $m->invoke($o, $test, $isAttribute)); } function testAttrs() { |