Added tests for specialchars quoting

pull/21/head
Aleksander Machniak 12 years ago
parent be71abeff9
commit 5f8097b9eb

@ -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('<', '&lt;'),
array('>', '&gt;'),
array('&', '&amp;'),
array('&amp;', '&amp;amp;'),
array('&amp;', '&amp;', true),
);
}
/**
* Test for quote()
* @dataProvider data_quote
*/
function test_quote($str, $result, $validate = false)
{
$this->assertEquals(html::quote($str, $validate), $result);
}
}

@ -129,6 +129,36 @@ class Framework_Utils extends PHPUnit_Framework_TestCase
$this->assertFalse(rcube_utils::check_ip($ip));
}
/**
* Data for test_rep_specialchars_output()
*/
function data_rep_specialchars_output()
{
return array(
array('', '', 'abc', 'abc'),
array('', '', '?', '?'),
array('', '', '"', '&quot;'),
array('', '', '<', '&lt;'),
array('', '', '>', '&gt;'),
array('', '', '&', '&amp;'),
array('', '', '&amp;', '&amp;amp;'),
array('', '', '<a>', '&lt;a&gt;'),
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()
*/

Loading…
Cancel
Save