mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
added test-cases for escape-modifier
This commit is contained in:
@@ -201,6 +201,9 @@ class SmartyTest extends PHPUnit_TestCase {
|
|||||||
function test_clear_config_method_exists() {
|
function test_clear_config_method_exists() {
|
||||||
$this->assertTrue(method_exists($this->smarty, 'clear_config'));
|
$this->assertTrue(method_exists($this->smarty, 'clear_config'));
|
||||||
}
|
}
|
||||||
|
function test_get_plugin_filepath() {
|
||||||
|
$this->assertTrue(method_exists($this->smarty, '_get_plugin_filepath'));
|
||||||
|
}
|
||||||
|
|
||||||
/* DISPLAY TESTS */
|
/* DISPLAY TESTS */
|
||||||
|
|
||||||
@@ -246,5 +249,65 @@ class SmartyTest extends PHPUnit_TestCase {
|
|||||||
$this->assertEquals($this->smarty->_config[0]['vars']['foo'], 'bar');
|
$this->assertEquals($this->smarty->_config[0]['vars']['foo'], 'bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test loading and running modifier.escape.php
|
||||||
|
function test_escape_modifier_get_plugins_filepath() {
|
||||||
|
$filepath = $this->smarty->_get_plugin_filepath('modifier', 'escape');
|
||||||
|
$this->assertEquals((bool)$filepath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_escape_modifier_include_file() {
|
||||||
|
$filepath = $this->smarty->_get_plugin_filepath('modifier', 'escape');
|
||||||
|
$success = include $filepath;
|
||||||
|
$this->assertEquals((bool)$success, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_escape_modifier_function_exists() {
|
||||||
|
$this->assertEquals(function_exists('smarty_modifier_escape'), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_escape_modifier_escape_default() {
|
||||||
|
$string = smarty_modifier_escape("<html><body></body></html>");
|
||||||
|
$this->assertEquals('<html><body></body></html>',
|
||||||
|
$string);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_escape_modifier_escape_html() {
|
||||||
|
$string = smarty_modifier_escape("<html><body></body></html>", 'html');
|
||||||
|
$this->assertEquals('<html><body></body></html>',
|
||||||
|
$string);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_escape_modifier_escape_htmlall() {
|
||||||
|
$string = smarty_modifier_escape("<html><body></body></html>", 'htmlall');
|
||||||
|
$this->assertEquals('<html><body></body></html>',
|
||||||
|
$string);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_escape_modifier_escape_url() {
|
||||||
|
$string = smarty_modifier_escape("http://test.com?foo=bar", 'url');
|
||||||
|
$this->assertEquals('http%3A%2F%2Ftest.com%3Ffoo%3Dbar', $string);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_escape_modifier_escape_quotes() {
|
||||||
|
$string = smarty_modifier_escape("'\\'\\''", 'quotes');
|
||||||
|
$this->assertEquals("\\'\\'\\'\\'", $string);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_escape_modifier_escape_hex() {
|
||||||
|
$string = smarty_modifier_escape("abcd", 'hex');
|
||||||
|
$this->assertEquals('%61%62%63%64', $string);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_escape_modifier_escape_hexentity() {
|
||||||
|
$string = smarty_modifier_escape("ABCD", 'hexentity');
|
||||||
|
$this->assertEquals('ABCD', $string);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_escape_modifier_escape_javascript() {
|
||||||
|
$string = smarty_modifier_escape("\r\n\\", 'javascript');
|
||||||
|
$this->assertEquals('\\r\\n\\\\', $string);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user