diff options
| author | Simon Wisselink <wisskid@users.noreply.github.com> | 2024-03-15 10:26:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-15 10:26:17 +0100 |
| commit | 17da1f585eb0d02c5b55d42d681ab4df77d7538e (patch) | |
| tree | f1bf43be5405206b6a3e170e1264c299ab2861a3 /tests | |
| parent | 293bc20db0f30de54db663ae238c681af90847d9 (diff) | |
| download | smarty-17da1f585eb0d02c5b55d42d681ab4df77d7538e.tar.gz smarty-17da1f585eb0d02c5b55d42d681ab4df77d7538e.tar.bz2 smarty-17da1f585eb0d02c5b55d42d681ab4df77d7538e.zip | |
Fix Too many shorthand attributes error when using a modifier as a function with more than 3 parameters in an expression (#953)
Fixes #949
Diffstat (limited to 'tests')
3 files changed, 18 insertions, 22 deletions
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/TimeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/TimeTest.php deleted file mode 100644 index d64fd92d..00000000 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/TimeTest.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -namespace UnitTests\TemplateSource\TagTests\PluginFunction; -class TimeTest extends \PHPUnit_Smarty { - - public function setUp(): void { - $this->setUpSmarty(__DIR__); - } - - public function testBasicSyntax() { - $this->assertStringMatchesFormat('%d', $this->smarty->fetch("string:{time()}")); - } - - public function testInvalidParameters() { - $this->expectException(\Smarty\Exception::class); - $this->expectExceptionMessage('Invalid number of arguments'); - $this->assertEquals("", $this->smarty->fetch("string:{time(3, 'foo')}")); - } - -}
\ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php index cfbb32bb..e2a38862 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php @@ -79,7 +79,7 @@ class PhpFunctionTest extends PHPUnit_Smarty public function testEmpty3() { $this->smarty->disableSecurity(); - $this->getSmarty()->registerPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'pass', function ($v) { return $v; }); + $this->getSmarty()->registerPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'pass', function ($v) { return $v; }); $this->smarty->assign('var', array(true, (int) 1, (float) 0.1, @@ -99,7 +99,7 @@ class PhpFunctionTest extends PHPUnit_Smarty public function testEmpty4() { $this->smarty->disableSecurity(); - $this->getSmarty()->registerPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'pass', function ($v) { return $v; }); + $this->getSmarty()->registerPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'pass', function ($v) { return $v; }); $this->smarty->assign('var', new TestIsset()); $expected = ' true , false , false , true , true , true , false '; $this->assertEquals($expected, $this->smarty->fetch('string:{strip}{if empty($var->isNull)} true {else} false {/IF} diff --git a/tests/UnitTests/TemplateSource/_Issues/TooManyShorthandAttributes949Test.php b/tests/UnitTests/TemplateSource/_Issues/TooManyShorthandAttributes949Test.php new file mode 100644 index 00000000..cfe55752 --- /dev/null +++ b/tests/UnitTests/TemplateSource/_Issues/TooManyShorthandAttributes949Test.php @@ -0,0 +1,16 @@ +<?php + +class TooManyShorthandAttributes949Test extends PHPUnit_Smarty +{ + + public function testPregMatchAll() { + $smarty = new \Smarty\Smarty(); + $smarty->registerPlugin('modifier', 'var_dump', 'var_dump'); + $templateStr = "eval:{\$a = 'blah'}{\$b = array()}{if var_dump('', \$a, \$b, 2)|noprint}blah{else}nah{/if}"; + $this->assertEquals( + 'nah', + $smarty->fetch($templateStr) + ); + } + +}
\ No newline at end of file |
