Added some extra unit test

This commit is contained in:
Simon Wisselink
2023-10-22 23:55:07 +02:00
parent babec0f29b
commit 9ee3cce380
3 changed files with 22 additions and 6 deletions

View File

@@ -591,6 +591,8 @@ class Template extends BaseCompiler {
* @return ?\Smarty\Compile\CompilerInterface tag compiler object or null if not found or untrusted by security policy
*/
public function getTagCompiler($tag): ?\Smarty\Compile\CompilerInterface {
$tag = strtolower($tag);
$tag = strtolower($tag);
if (isset($this->smarty->security_policy) && !$this->smarty->security_policy->isTrustedTag($tag, $this)) {

View File

@@ -167,15 +167,29 @@ class RegisterFunctionTest extends PHPUnit_Smarty
$this->assertIsArray($this->smarty->getRegisteredPlugin(Smarty::PLUGIN_BLOCK, 'testfunction'));
}
/**
* Test case (in)sensitivy of plugin functions
* @param $registerName
* @param $templateString
* @return void
* @throws \Smarty\Exception
* @group issue907
* @dataProvider dataProviderForCaseSensitivity
*/
public function testCaseSensitivity() {
$this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'customTag', 'myfunction');
$this->assertEquals('hello world ', $this->smarty->fetch('string:{customTag}'));
public function testCaseSensitivity($registerName, $templateString) {
$this->smarty->registerPlugin(
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}'],
];
}
}