mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 09:54:27 +02:00
Add unit tests to clarify current behavior
This commit is contained in:
@@ -30,4 +30,36 @@ class AutoEscapeTest extends PHPUnit_Smarty
|
||||
$tpl->assign('foo', '<a@b.c>');
|
||||
$this->assertEquals("<a@b.c>", $this->smarty->fetch($tpl));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test 'escapeHtml' property
|
||||
* @group issue906
|
||||
*/
|
||||
public function testAutoEscapeDoesNotEscapeFunctionPlugins()
|
||||
{
|
||||
$this->smarty->registerPlugin(
|
||||
Smarty::PLUGIN_FUNCTION,
|
||||
'horizontal_rule',
|
||||
function ($params, $smarty) { return "<hr>"; }
|
||||
);
|
||||
$tpl = $this->smarty->createTemplate('eval:{horizontal_rule}');
|
||||
$this->assertEquals("<hr>", $this->smarty->fetch($tpl));
|
||||
}
|
||||
|
||||
/**
|
||||
* test 'escapeHtml' property
|
||||
* @group issue906
|
||||
*/
|
||||
public function testAutoEscapeDoesNotEscapeBlockPlugins()
|
||||
{
|
||||
$this->smarty->registerPlugin(
|
||||
Smarty::PLUGIN_BLOCK,
|
||||
'paragraphify',
|
||||
function ($params, $content) { return $content == null ? null : "<p>".$content."</p>"; }
|
||||
);
|
||||
$tpl = $this->smarty->createTemplate('eval:{paragraphify}hi{/paragraphify}');
|
||||
$this->assertEquals("<p>hi</p>", $this->smarty->fetch($tpl));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user