diff --git a/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php b/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php index b4c30721..7e6c9dc4 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php @@ -62,59 +62,4 @@ class CompileAppendTest extends PHPUnit_Smarty array('{$foo[]=2}{$foo|var_export:true}', 'array(0=>2,)', '', $i ++), ); } - - /** - * Test scope - * - * @run InSeparateProcess - * @preserveGlobalState disabled - * @dataProvider dataTestScope - */ - public function testScope($code, $useSmarty, $result, $testName, $testNumber) - { - $file = "testScope_{$testNumber}.tpl"; - $this->makeTemplateFile($file, $code . '{checkvar var=foo}'); - $this->smarty->assignGlobal('file', $file); - $this->smarty->assign('foo', 'smarty'); - $this->smarty->assignGlobal('foo', 'global'); - $data1 = $this->smarty->createData($useSmarty ? $this->smarty : null); - $data = $this->smarty->createData($data1); - $data1->assign('foo', 'data1'); - $data->assign('foo', 'data'); - $this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('scope_tag.tpl', $data)), "test - {$code} - {$testName}"); - } - - /* - * Data provider für testscope - */ - public function dataTestScope() - { - $i = 0; - /* - * Code - * use Smarty object - * result - * test name - */ - return array( - array( - '{$foo[] = \'newvar\' scope=tpl_root}', true, - '#testScope_0.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#data:$foo=\'data\'#data:$foo=\'data1\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{$foo[] = \'newvar\' scope=tpl_root bubble_up}', true, - '#testScope_1.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#data:$foo=\'data\'#data:$foo=\'data1\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{append var=foo value=\'newvar\' scope=tpl_root}', true, - '#testScope_2.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#data:$foo=\'data\'#data:$foo=\'data1\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{append var=foo value=\'newvar\' scope=tpl_root bubble_up}', true, - '#testScope_3.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#data:$foo=\'data\'#data:$foo=\'data1\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), - ); - } - } diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php b/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php index d5143be5..de1f9a79 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php @@ -83,172 +83,4 @@ class CompileAssignTest extends PHPUnit_Smarty ), ); } - - /** - * Test scope - * - * @not runInSeparateProcess - * @preserveGlobalState disabled - * @dataProvider dataTestScope - */ - public function testScope($code, $useSmarty, $result, $testName, $testNumber) - { - $file = "testScope_{$testNumber}.tpl"; - $this->makeTemplateFile($file, $code . '{checkvar var=foo}'); - $this->smarty->assignGlobal('file', $file); - $this->smarty->assign('foo', 'smarty'); - $this->smarty->assignGlobal('foo', 'global'); - $data = $this->smarty->createData($useSmarty ? $this->smarty : null); - $data->assign('foo', 'data'); - $this->assertEquals($this->strip('#' . $file . $result), $this->strip($this->smarty->fetch('scope_tag.tpl', $data)), "test - {$code} - {$testName}"); - } - - /* - * Data provider für testscope - */ - public function dataTestScope() - { - $i = 1; - /* - * Code - * use Smarty object - * result - * test name - */ - return array( - array( - '{$foo = \'newvar\'}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{assign var=foo value=\'newvar\'}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{$foo = \'newvar\' bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{$foo = \'newvar\' scope=local}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{$foo = \'newvar\' scope=local bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{assign var=foo value=\'newvar\' bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{assign var=foo value=\'newvar\' scope=local}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{assign var=foo value=\'newvar\' scope=local bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{$foo = \'newvar\' scope=parent}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{$foo = \'newvar\' scope=parent bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{assign var=foo value=\'newvar\' scope=parent}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{assign var=foo value=\'newvar\' scope=parent bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{$foo = \'newvar\' scope=tpl_root}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{$foo = \'newvar\' scope=tpl_root bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{$foo = \'newvar\' scope=global}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'newvar\'', - '', $i ++, - ), array( - '{$foo = \'newvar\' scope=global bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'newvar\'', - '', $i ++, - ), array( - '{$foo = \'newvar\' scope=root}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{$foo = \'newvar\' scope=root bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{$foo = \'newvar\' scope=root}', false, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - 'no smarty', $i ++, - ), array( - '{$foo = \'newvar\' scope=root bubble_up}', false, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', - 'no smarty', $i ++, - ), array( - '{$foo = \'newvar\' scope=smarty}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'newvar\'#global:$foo=\'global\'', - '', $i ++, - ), array( - '{$foo = \'newvar\' scope=smarty bubble_up}', false, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'newvar\'#global:$foo=\'global\'', - 'no smarty', $i ++, - ), - ); - } - - /** - * Test scope nocache - * - * @runInSeparateProcess - * @preserveGlobalState disabled - * @dataProvider dataTestScopeNocache - */ - public function testScopeNocache($var, $file, $result) - { - $this->smarty->setCaching(true); - $this->smarty->assign('bar', $var, true); - $this->smarty->assign('buh', $var); - $this->smarty->assign('foo', 'smarty'); - $this->smarty->assignGlobal('foo', 'global'); - $this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch($file)), "test - {$file} {$var}"); - } - - /* - * Data provider für testscopenocache - */ - public function dataTestScopeNocache() - { - /* - * variable value - * result - */ - return array( - array( - 'b1', 'test_scope_assignbar.tpl', - '#test_scope_assignbar.tpl:$foo=\'b1\'#Smarty:$foo=\'smarty\'#global:$foo=\'b1\'', - ), array( - 'b2', 'test_scope_assignbar.tpl', - '#test_scope_assignbar.tpl:$foo=\'b2\'#Smarty:$foo=\'smarty\'#global:$foo=\'b2\'', - ), array( - 'b1', 'test_scope_assignnocache.tpl', - '#test_scope_assignnocache.tpl:$foo=\'b1\'#Smarty:$foo=\'smarty\'#global:$foo=\'b1\'', - ), array( - 'b2', 'test_scope_assignnocache.tpl', - '#test_scope_assignnocache.tpl:$foo=\'b2\'#Smarty:$foo=\'smarty\'#global:$foo=\'b2\'', - ), - ); - } - } diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php index 7d192c35..ceb633eb 100644 --- a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php @@ -135,95 +135,4 @@ class CompileConfigLoadTest extends PHPUnit_Smarty { $this->smarty->fetch('eval:{config_load file=\'test_error.conf\'}'); } - - /** - * Test scope - * - * @not runInSeparateProcess - * @preserveGlobalState disabled - * @dataProvider dataTestScope - */ - public function testScope($code, $useSmarty, $result, $testName, $testNumber) - { - $file = "testScope_{$testNumber}.tpl"; - $this->makeTemplateFile($file, $code . '{checkconfigvar var=foo}'); - $this->smarty->assignGlobal('file', $file); - $this->smarty->configLoad('smarty.conf'); - $data = $this->smarty->createData($useSmarty ? $this->smarty : null); - $data->configLoad('data.conf'); - $this->assertEquals($this->strip('#' . $file . $result), $this->strip($this->smarty->fetch('scope_tag.tpl', $data)), "test - {$code} - {$testName}"); - } - - /* - * Data provider für testscope - */ - public function dataTestScope() - { - $i = 1; - /* - * Code - * use Smarty object - * result - * test name - */ - return array( - array( - '{config_load \'template.conf\'}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'', - '', $i ++, - ), array( - '{config_load \'template.conf\' bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'', - '', $i ++, - ), array( - '{config_load \'template.conf\' scope=local}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'', - '', $i ++, - ), array( - '{config_load \'template.conf\' scope=local bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'', - '', $i ++, - ), array( - '{config_load \'template.conf\' scope=parent}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'', - '', $i ++, - ), array( - '{config_load \'template.conf\' scope=parent bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'', - '', $i ++, - ), array( - '{config_load \'template.conf\' scope=tpl_root}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'', - '', $i ++, - ), array( - '{config_load \'template.conf\' scope=tpl_root bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'', - '', $i ++, - ), array( - '{config_load \'template.conf\' scope=root}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'', - '', $i ++, - ), array( - '{config_load \'template.conf\' scope=root bubble_up}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'', - '', $i ++, - ), array( - '{config_load \'template.conf\' scope=root}', false, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'', - 'no smarty', $i ++, - ), array( - '{config_load \'template.conf\' scope=root bubble_up}', false, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'', - 'no smarty', $i ++, - ), array( - '{config_load \'template.conf\' scope=smarty}', true, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'newvar\'', - '', $i ++, - ), array( - '{config_load \'template.conf\' scope=smarty bubble_up}', false, - ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'newvar\'', - 'no smarty', $i ++, - ), - ); - } } diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php b/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php index 6ada592d..1d7636fe 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php @@ -172,62 +172,6 @@ class CompileIncludeTest extends PHPUnit_Smarty } - /** - * Test scope - * - * @run InSeparateProcess - * @preserveGlobalState disabled - * @dataProvider dataTestScope - */ - public function testScope($code, $useSmarty, $result, $testName, $testNumber = null) - { - if ($testNumber) { - $file = "testScope_{$testNumber}.tpl"; - $this->makeTemplateFile($file, $code); - $this->smarty->assignGlobal('file', $file); - } - $this->smarty->assign('foo', 'smarty'); - $this->smarty->assignGlobal('foo', 'global'); - $data = $this->smarty->createData($useSmarty ? $this->smarty : null); - $data->assign('foo', 'data'); - if (!$useSmarty) { - $testName .= 'no smarty'; - } - $this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('test_scope.tpl', $data)), - "test - {$code} - {$testName}"); - } - - /* - * Data provider for testscope - */ - public function dataTestScope() - { - $i = 1; - return array(/* - * Code - * use Smarty object - * result - * test name - */ - array('{include \'test_scope_assign.tpl\'}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'data\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), - array('{include \'test_scope_assign.tpl\' bubble_up}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'data\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), - array('{include \'test_scope_assign.tpl\' scope=parent}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), - array('{include \'test_scope_assign.tpl\' scope=parent bubble_up}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), - array('{include \'test_scope_assign.tpl\' scope=tpl_root}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'data\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), - array('{include \'test_scope_assign.tpl\' scope=tpl_root bubble_up}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), - array('{include \'test_scope_assign.tpl\' scope=root}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'data\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), - array('{include \'test_scope_assign.tpl\' scope=root bubble_up}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), - array('{include \'test_scope_assign.tpl\' scope=root}', false, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'data\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), - array('{include \'test_scope_assign.tpl\' scope=root bubble_up}', false, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), - array('{include \'test_scope_assign.tpl\' scope=smarty}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'data\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'newvar\'#global:$foo=\'global\'', '', $i++), - array('{include \'test_scope_assign.tpl\' scope=smarty bubble_up}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'newvar\'#global:$foo=\'global\'', '', $i++), - array('{include \'test_scope_assign.tpl\' scope=global}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'data\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'newvar\'', '', $i++), - array('{include \'test_scope_assign.tpl\' scope=global bubble_up}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'newvar\'', '', $i++), - array('{include \'test_scope_pluginassign.tpl\' scope=global}', true, '#test_scope_pluginassign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'data\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'newvar\'', '', $i++), - array('{include \'test_scope_pluginassign.tpl\' scope=global bubble_up}', true, '#test_scope_pluginassign.tpl:$foo=\'newvar\'#testScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'newvar\'', '', $i++), - ); - } - /** diff --git a/tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php b/tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php new file mode 100644 index 00000000..fe5476c4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php @@ -0,0 +1,321 @@ +setUpSmarty(dirname(__FILE__)); + $this->smarty->addPluginsDir("../../__shared/PHPunitplugins/"); + $this->smarty->addTemplateDir("../../__shared/templates/"); + $this->smarty->addTemplateDir("./templates_tmp"); + } + + public function testInit() + { + $this->cleanDirs(); + } + + /** + * Test scope + * + * @run InSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestAppendScope + */ + public function testAppendScope($code, $useSmarty, $result, $testName, $testNumber) + { + $file = "testAppendScope_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code . '{checkvar var=foo}'); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('foo', 'smarty'); + $this->smarty->assignGlobal('foo', 'global'); + $data1 = $this->smarty->createData($useSmarty ? $this->smarty : null); + $data = $this->smarty->createData($data1); + $data1->assign('foo', 'data1'); + $data->assign('foo', 'data'); + $this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('scope_tag.tpl', $data)), "test - {$code} - {$testName}"); + } + + /* + * Data provider für testAppendScope + */ + public function dataTestAppendScope() + { + $i = 0; + /* + * Code + * use Smarty object + * result + * test name + */ + return array( + array( + '{$foo[] = \'newvar\' scope=tpl_root}', true, + '#testAppendScope_0.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#data:$foo=\'data\'#data:$foo=\'data1\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', + '', $i ++, + ), array( + '{append var=foo value=\'newvar\' scope=tpl_root}', true, + '#testAppendScope_1.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#data:$foo=\'data\'#data:$foo=\'data1\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', + '', $i ++, + ), array( + '{append var=foo value=\'newvar\' scope=global}', true, + '#testAppendScope_2.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#data:$foo=\'data\'#data:$foo=\'data1\'#Smarty:$foo=\'smarty\'#global:$foo=array(0=>\'data\',1=>\'newvar\',)', + '', $i ++, + ), array( + '{append var=foo value=\'newvar\' scope=smarty}', true, + '#testAppendScope_3.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#data:$foo=\'data\'#data:$foo=\'data1\'#Smarty:$foo=array(0=>\'data\',1=>\'newvar\',)#global:$foo=\'global\'', + '', $i ++, + ), + ); + } + /** + * Test scope + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestAssignScope + */ + public function testAssignScope($code, $useSmarty, $result, $testName, $testNumber) + { + $file = "testAssignScope_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code . '{checkvar var=foo}'); + $this->smarty->assignGlobal('file', $file); + $this->smarty->assign('foo', 'smarty'); + $this->smarty->assignGlobal('foo', 'global'); + $data = $this->smarty->createData($useSmarty ? $this->smarty : null); + $data->assign('foo', 'data'); + $this->assertEquals($this->strip('#' . $file . $result), $this->strip($this->smarty->fetch('scope_tag.tpl', $data)), "test - {$code} - {$testName}"); + } + + /* + * Data provider für testAssignScope + */ + public function dataTestAssignScope() + { + $i = 1; + /* + * Code + * use Smarty object + * result + * test name + */ + return array( + array( + '{$foo = \'newvar\'}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', + '', $i ++, + ), array( + '{assign var=foo value=\'newvar\'}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', + '', $i ++, + ), array( + '{$foo = \'newvar\' scope=local}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', + '', $i ++, + ), array( + '{assign var=foo value=\'newvar\' scope=local}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', + '', $i ++, + ), array( + '{$foo = \'newvar\' scope=parent}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', + '', $i ++, + ), array( + '{assign var=foo value=\'newvar\' scope=parent}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', + '', $i ++, + ), array( + '{$foo = \'newvar\' scope=tpl_root}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', + '', $i ++, + ), array( + '{$foo = \'newvar\' scope=global}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'newvar\'', + '', $i ++, + ), array( + '{$foo = \'newvar\' scope=root}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', + '', $i ++, + ), array( + '{$foo = \'newvar\' scope=root}', false, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', + 'no smarty', $i ++, + ), array( + '{$foo = \'newvar\' scope=smarty}', false, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'newvar\'#global:$foo=\'global\'', + 'no smarty', $i ++, + ), + ); + } + + /** + * Test scope nocache + * + * @runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestScopeNocache + */ + public function testScopeNocache($var, $file, $result) + { + $this->smarty->setCaching(true); + $this->smarty->assign('bar', $var, true); + $this->smarty->assign('buh', $var); + $this->smarty->assign('foo', 'smarty'); + $this->smarty->assignGlobal('foo', 'global'); + $this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch($file)), "test - {$file} {$var}"); + } + + /* + * Data provider für testscopenocache + */ + public function dataTestScopeNocache() + { + /* + * variable value + * result + */ + return array( + array( + 'b1', 'test_scope_assignbar.tpl', + '#test_scope_assignbar.tpl:$foo=\'b1\'#Smarty:$foo=\'smarty\'#global:$foo=\'b1\'', + ), array( + 'b2', 'test_scope_assignbar.tpl', + '#test_scope_assignbar.tpl:$foo=\'b2\'#Smarty:$foo=\'smarty\'#global:$foo=\'b2\'', + ), array( + 'b1', 'test_scope_assignnocache.tpl', + '#test_scope_assignnocache.tpl:$foo=\'b1\'#Smarty:$foo=\'smarty\'#global:$foo=\'b1\'', + ), array( + 'b2', 'test_scope_assignnocache.tpl', + '#test_scope_assignnocache.tpl:$foo=\'b2\'#Smarty:$foo=\'smarty\'#global:$foo=\'b2\'', + ), + ); + } + /** + * Test scope + * + * @run InSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestIncludeScope + */ + public function testIncludeScope($code, $useSmarty, $result, $testName, $testNumber = null) + { + if ($testNumber) { + $file = "testIncludeScope_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code); + $this->smarty->assignGlobal('file', $file); + } + $this->smarty->assign('foo', 'smarty'); + $this->smarty->assignGlobal('foo', 'global'); + $data = $this->smarty->createData($useSmarty ? $this->smarty : null); + $data->assign('foo', 'data'); + if (!$useSmarty) { + $testName .= 'no smarty'; + } + $this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('test_scope.tpl', $data)), + "test - {$code} - {$testName}"); + } + + /* + * Data provider for testIncludeScope + */ + public function dataTestIncludeScope() + { + $i = 1; + return array(/* + * Code + * use Smarty object + * result + * test name + */ + array('{include \'test_scope_assign.tpl\'}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_'.$i.'.tpl:$foo=\'data\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), + array('{include \'test_scope_assign.tpl\' scope=parent}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), + array('{include \'test_scope_assign.tpl\' scope=tpl_root}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), + array('{include \'test_scope_assign.tpl\' scope=root}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), + array('{include \'test_scope_assign.tpl\' scope=root}', false, '#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'', '', $i++), + array('{include \'test_scope_assign.tpl\' scope=smarty}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'newvar\'#global:$foo=\'global\'', '', $i++), + array('{include \'test_scope_assign.tpl\' scope=global}', true, '#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'newvar\'', '', $i++), + array('{include \'test_scope_pluginassign.tpl\' scope=global}', true, '#test_scope_pluginassign.tpl:$foo=\'newvar\'#testIncludeScope_'.$i.'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'newvar\'', '', $i++), + ); + } + /** + * Test scope + * + * @not runInSeparateProcess + * @preserveGlobalState disabled + * @dataProvider dataTestConfigScope + */ + public function testConfigScope($code, $useSmarty, $result, $testName, $testNumber) + { + $file = "testConfigScope_{$testNumber}.tpl"; + $this->makeTemplateFile($file, $code . '{checkconfigvar var=foo}'); + $this->smarty->assignGlobal('file', $file); + $this->smarty->configLoad('smarty.conf'); + $data = $this->smarty->createData($useSmarty ? $this->smarty : null); + $data->configLoad('data.conf'); + $this->assertEquals($this->strip('#' . $file . $result), $this->strip($this->smarty->fetch('scope_tag.tpl', $data)), "test - {$code} - {$testName}"); + } + + /* + * Data provider für testConfigScope + */ + public function dataTestConfigScope() + { + $i = 1; + /* + * Code + * use Smarty object + * result + * test name + */ + return array( + array( + '{config_load \'template.conf\'}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'', + '', $i ++, + ), array( + '{config_load \'template.conf\' scope=local}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'', + '', $i ++, + ), array( + '{config_load \'template.conf\' scope=parent}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'', + '', $i ++, + ), array( + '{config_load \'template.conf\' scope=tpl_root}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'', + '', $i ++, + ), array( + '{config_load \'template.conf\' scope=root}', true, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'', + '', $i ++, + ), array( + '{config_load \'template.conf\' scope=root}', false, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'', + 'no smarty', $i ++, + ), array( + '{config_load \'template.conf\' scope=smarty}', false, + ':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'newvar\'', + 'no smarty', $i ++, + ), + ); + } + + public function testFunctionScope() { + $this->smarty->assign('scope', 'none'); + $r = $this->smarty->fetch('test_function_scope.tpl'); + + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/Append/cache/dummy.txt b/tests/UnitTests/TemplateSource/X_Scopes/cache/dummy.txt similarity index 100% rename from tests/UnitTests/TemplateSource/TagTests/Append/cache/dummy.txt rename to tests/UnitTests/TemplateSource/X_Scopes/cache/dummy.txt diff --git a/tests/UnitTests/TemplateSource/X_Scopes/configs/data.conf b/tests/UnitTests/TemplateSource/X_Scopes/configs/data.conf new file mode 100644 index 00000000..c9349c71 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/configs/data.conf @@ -0,0 +1 @@ +foo = data diff --git a/tests/UnitTests/TemplateSource/X_Scopes/configs/smarty.conf b/tests/UnitTests/TemplateSource/X_Scopes/configs/smarty.conf new file mode 100644 index 00000000..d65d1fd0 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/configs/smarty.conf @@ -0,0 +1 @@ +foo = smarty diff --git a/tests/UnitTests/TemplateSource/X_Scopes/configs/template.conf b/tests/UnitTests/TemplateSource/X_Scopes/configs/template.conf new file mode 100644 index 00000000..303000d4 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/configs/template.conf @@ -0,0 +1 @@ +foo = newvar diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope.tpl new file mode 100644 index 00000000..3aad88bf --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope.tpl @@ -0,0 +1,35 @@ +{strip} + {function 'a'} + {call 'b'} + {/function} +{function 'b'} + {include 'test_function_scope_include.tpl'} +{/function} +{function c} + {call $scope} +{/function} +{function 'none'} + {$foo = 'newvar'} + {checkvar var=foo} +{/function} +{function 'local'} + {$foo = 'newvar' scope='local'} + {checkvar var=foo} +{/function} +{function 'parent'} + {$foo = 'newvar' scope='parent'} + {checkvar var=foo} +{/function} +{function 'tpl_root'} + {$foo = 'newvar' scope='tpl_root'} + {checkvar var=foo} +{/function} +{function 'smarty'} + {$foo = 'newvar' scope='smarty'} + {checkvar var=foo} +{/function} +{function 'global'} + {$foo = 'newvar' scope='global'} + {checkvar var=foo} +{/function} +{call 'a'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope_include.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope_include.tpl new file mode 100644 index 00000000..5428e13d --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_function_scope_include.tpl @@ -0,0 +1,2 @@ +{strip} + {call 'c'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope.tpl new file mode 100644 index 00000000..bfb1e6cb --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope.tpl @@ -0,0 +1 @@ +{include $file} diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign.tpl new file mode 100644 index 00000000..ae7268d8 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assign.tpl @@ -0,0 +1 @@ +{$foo = 'newvar'}{checkvar var=foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignbar.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignbar.tpl new file mode 100644 index 00000000..c0be3a40 --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignbar.tpl @@ -0,0 +1 @@ +{$foo = $bar scope=global}{checkvar var=foo nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignnocache.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignnocache.tpl new file mode 100644 index 00000000..4bde90af --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_assignnocache.tpl @@ -0,0 +1 @@ +{$foo = $buh scope=global nocache}{checkvar var=foo nocache} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_pluginassign.tpl b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_pluginassign.tpl new file mode 100644 index 00000000..e19a560a --- /dev/null +++ b/tests/UnitTests/TemplateSource/X_Scopes/templates/test_scope_pluginassign.tpl @@ -0,0 +1 @@ +{pluginassign var=foo value='newvar'}{checkvar var=foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/cache/dummy.txt b/tests/UnitTests/TemplateSource/X_Scopes/templates_c/dummy.txt similarity index 100% rename from tests/UnitTests/TemplateSource/TagTests/Assign/cache/dummy.txt rename to tests/UnitTests/TemplateSource/X_Scopes/templates_c/dummy.txt diff --git a/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php b/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php index 55fa76fc..5d549c8b 100644 --- a/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php +++ b/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php @@ -27,6 +27,12 @@ function smarty_function_checkvar($params, $template) if (in_array('template', $types) && $ptr instanceof Smarty_Internal_Template) { $output .= "#{$ptr->source->name}:\${$var} ="; $output .= isset($ptr->tpl_vars[$var]) ? preg_replace('/\s/', '', var_export($ptr->tpl_vars[$var]->value, true)) : '>unassigned<'; + $i = 0; + while (isset($ptr->_cache[ 'varStack' ][ $i ])) { + $output .= "#{$ptr->_cache[ 'varStack' ][ $i ]['name']} = "; + $output .= isset($ptr->_cache[ 'varStack' ][ $i ][ 'tpl' ][$var]) ? preg_replace('/\s/', '', var_export($ptr->_cache[ 'varStack' ][ $i ][ 'tpl' ][$var]->value, true)) : '>unassigned<'; + $i ++; + } $ptr = $ptr->parent; } elseif (in_array('data', $types) && $ptr instanceof Smarty_Data) { $output .= "#data:\${$var} =";