diff options
author | Aleksander Machniak <alec@alec.pl> | 2012-08-27 12:55:58 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2012-08-27 12:55:58 +0200 |
commit | 5f8097b9eba09302be561d67ce035275494043e3 (patch) | |
tree | a626f76ceefcab171311767aba8ca5db5525b782 | |
parent | be71abeff913611086e4f36f6888bf57666042c5 (diff) |
Added tests for specialchars quoting
-rw-r--r-- | tests/Framework/Html.php | 26 | ||||
-rw-r--r-- | tests/Framework/Utils.php | 30 |
2 files changed, 56 insertions, 0 deletions
diff --git a/tests/Framework/Html.php b/tests/Framework/Html.php index 107f82805..8a27baca8 100644 --- a/tests/Framework/Html.php +++ b/tests/Framework/Html.php @@ -17,4 +17,30 @@ class Framework_Html extends PHPUnit_Framework_TestCase $this->assertInstanceOf('html', $object, "Class constructor"); } + + /** + * Data for test_quote() + */ + function data_quote() + { + return array( + array('abc', 'abc'), + array('?', '?'), + array('"', '"'), + array('<', '<'), + array('>', '>'), + array('&', '&'), + array('&', '&amp;'), + array('&', '&', true), + ); + } + + /** + * Test for quote() + * @dataProvider data_quote + */ + function test_quote($str, $result, $validate = false) + { + $this->assertEquals(html::quote($str, $validate), $result); + } } diff --git a/tests/Framework/Utils.php b/tests/Framework/Utils.php index 503b69a4a..e58835956 100644 --- a/tests/Framework/Utils.php +++ b/tests/Framework/Utils.php @@ -130,6 +130,36 @@ class Framework_Utils extends PHPUnit_Framework_TestCase } /** + * Data for test_rep_specialchars_output() + */ + function data_rep_specialchars_output() + { + return array( + array('', '', 'abc', 'abc'), + array('', '', '?', '?'), + array('', '', '"', '"'), + array('', '', '<', '<'), + array('', '', '>', '>'), + array('', '', '&', '&'), + array('', '', '&', '&amp;'), + array('', '', '<a>', '<a>'), + array('', 'remove', '<a>', ''), + ); + } + + /** + * Test for rep_specialchars_output + * @dataProvider data_rep_specialchars_output + */ + function test_rep_specialchars_output($type, $mode, $str, $res) + { + $result = rcube_utils::rep_specialchars_output( + $str, $type ? $type : 'html', $mode ? $mode : 'strict'); + + $this->assertEquals($result, $res); + } + + /** * rcube_utils::mod_css_styles() */ function test_mod_css_styles() |