mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-01 00:44:26 +02:00
Added some extra unit test
This commit is contained in:
@@ -593,6 +593,8 @@ class Template extends BaseCompiler {
|
|||||||
public function getTagCompiler($tag): ?\Smarty\Compile\CompilerInterface {
|
public function getTagCompiler($tag): ?\Smarty\Compile\CompilerInterface {
|
||||||
$tag = strtolower($tag);
|
$tag = strtolower($tag);
|
||||||
|
|
||||||
|
$tag = strtolower($tag);
|
||||||
|
|
||||||
if (isset($this->smarty->security_policy) && !$this->smarty->security_policy->isTrustedTag($tag, $this)) {
|
if (isset($this->smarty->security_policy) && !$this->smarty->security_policy->isTrustedTag($tag, $this)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -261,7 +261,7 @@ class Security {
|
|||||||
* @return boolean true if tag is trusted
|
* @return boolean true if tag is trusted
|
||||||
*/
|
*/
|
||||||
public function isTrustedTag($tag_name, $compiler) {
|
public function isTrustedTag($tag_name, $compiler) {
|
||||||
$tag_name = strtolower($tag_name);
|
$tag_name = strtolower($tag_name);
|
||||||
|
|
||||||
// check for internal always required tags
|
// check for internal always required tags
|
||||||
if (in_array($tag_name, ['assign', 'call'])) {
|
if (in_array($tag_name, ['assign', 'call'])) {
|
||||||
|
@@ -154,7 +154,7 @@ class RegisterFunctionTest extends PHPUnit_Smarty
|
|||||||
public function testUnregisterFunctionNotRegistered()
|
public function testUnregisterFunctionNotRegistered()
|
||||||
{
|
{
|
||||||
$this->smarty->unregisterPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction');
|
$this->smarty->unregisterPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction');
|
||||||
$this->assertNull($this->smarty->getRegisteredPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction'));
|
$this->assertNull($this->smarty->getRegisteredPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,18 +164,32 @@ class RegisterFunctionTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testfunction', 'myfunction');
|
$this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testfunction', 'myfunction');
|
||||||
$this->smarty->unregisterPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction');
|
$this->smarty->unregisterPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction');
|
||||||
$this->assertIsArray($this->smarty->getRegisteredPlugin(Smarty::PLUGIN_BLOCK, 'testfunction'));
|
$this->assertIsArray($this->smarty->getRegisteredPlugin(Smarty::PLUGIN_BLOCK, 'testfunction'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test case (in)sensitivy of plugin functions
|
* Test case (in)sensitivy of plugin functions
|
||||||
|
* @param $registerName
|
||||||
|
* @param $templateString
|
||||||
* @return void
|
* @return void
|
||||||
* @throws \Smarty\Exception
|
* @throws \Smarty\Exception
|
||||||
* @group issue907
|
* @group issue907
|
||||||
|
* @dataProvider dataProviderForCaseSensitivity
|
||||||
*/
|
*/
|
||||||
public function testCaseSensitivity() {
|
public function testCaseSensitivity($registerName, $templateString) {
|
||||||
$this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'customTag', 'myfunction');
|
$this->smarty->registerPlugin(
|
||||||
$this->assertEquals('hello world ', $this->smarty->fetch('string:{customTag}'));
|
Smarty::PLUGIN_FUNCTION,
|
||||||
|
$registerName,
|
||||||
|
function($params, $smarty) { return 'function-output'; });
|
||||||
|
$this->assertEquals('function-output', $this->smarty->fetch('string:' . $templateString));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataProviderForCaseSensitivity() {
|
||||||
|
return [
|
||||||
|
['customTag', '{customTag}'],
|
||||||
|
['customtag', '{customtag}'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user