diff options
author | Asmir Mustafic <[email protected]> | 2014-02-04 16:57:23 +0100 |
---|---|---|
committer | Asmir Mustafic <[email protected]> | 2014-02-04 16:57:23 +0100 |
commit | 7713a8b8c0fa603732fb442c026d0144347cbd39 (patch) | |
tree | c4a0cd00414cecfafc65f591eb1481240197fd9b /test/HTML5/Serializer | |
parent | 4c79dfe22d635ba0e562117826d56a1d13b35e97 (diff) |
escaping attributes in a different way
Diffstat (limited to 'test/HTML5/Serializer')
-rw-r--r-- | test/HTML5/Serializer/OutputRulesTest.php | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/test/HTML5/Serializer/OutputRulesTest.php b/test/HTML5/Serializer/OutputRulesTest.php index 9c20a7f..b37b3b3 100644 --- a/test/HTML5/Serializer/OutputRulesTest.php +++ b/test/HTML5/Serializer/OutputRulesTest.php @@ -234,43 +234,37 @@ class OutputRulesTest extends \HTML5\Tests\TestCase { $m->invoke($o, 'foo'); $this->assertEquals('foo', stream_get_contents($s, -1, 0)); } - - function getEncData(){ - return array( - array('&\'<>"', '&\'<>"'), - array('This + is. a < test', 'This + is. a < test'), - array('.+#', '.+#'), - ); - } - - function getEncWithEntiyesData(){ + function getEncDataAttssribute(){ return array( - array('.+#', '.+#'), + array('&\'<>"', '&\'<>"', '&\'<>"'), + array('.+#', '.+#', '.+#'), ); } + function getEncData(){ + return array( + array(false, '&\'<>"', '&\'<>"', '&\'<>"'), + array(false, 'This + is. a < test', 'This + is. a < test', 'This + is. a < test'), + array(false, '.+#', '.+#', '.+#'), + array(true, '.+#\'', '.+#'', '.+#''), + array(true, '&".<', '&".<', '&".<'), + ); + } /** * Test basic escaping of text. * @dataProvider getEncData */ - function testEnc($test, $expected) { - - list($o, $s) = $this->getOutputRules(); - $m = $this->getProtectedMethod('enc'); - $this->assertEquals($expected, $m->invoke($o, $test)); + function testEnc($isAttribute, $test, $expected, $expectedEncoded) { - } + list($o, $s) = $this->getOutputRules(); + $m = $this->getProtectedMethod('enc'); - /** - * Test basic escaping of text. - * @dataProvider getEncWithEntiyesData - */ - function testEncWithEntities($test, $expected) { + $this->assertEquals($expected, $m->invoke($o, $test, $isAttribute)); list($o, $s) = $this->getOutputRules(array('encode_entities' => TRUE)); $m = $this->getProtectedMethod('enc'); - $this->assertEquals($expected, $m->invoke($o, $test)); + $this->assertEquals($expectedEncoded, $m->invoke($o, $test, $isAttribute)); } function testAttrs() { |