Update template function tests

This commit is contained in:
Uwe Tews
2018-03-28 07:02:18 +02:00
parent 8f8030805a
commit ced3bf86d8
2 changed files with 19 additions and 21 deletions

View File

@@ -114,33 +114,19 @@ class CompileFunctionTest extends PHPUnit_Smarty
/** /**
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
* @dataProvider functionProviderCaching * @dataProvider functionProviderCachingValue
* test simple function call tag plugin * test simple function call tag plugin
* *
*/ */
public function testSimpleFunctionPlugin_003($caching, $text) public function testSimpleFunctionPlugin_003($caching, $text, $start,$result)
{ {
$this->smarty->setCaching($caching); $this->smarty->setCaching($caching);
$this->smarty->assign('param', 1); $this->smarty->assign('start', $start, true);
$this->smarty->assign('default', 2, true); $this->smarty->assign('start1', $start+10);
$this->assertEquals("default 1", $this->smarty->fetch('test_template_function_003.tpl'), $text); $this->assertEquals($result, $this->smarty->fetch('test_template_function_003.tpl'), $text);
} }
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
* @dataProvider functionProvider
* test simple function call tag plugin nocache
*
*/
public function testSimpleFunctionCachedPluginNocache_003($text)
{
$this->smarty->setCaching(1);
$this->smarty->setCompileId(1);
$this->smarty->assign('param', 1);
$this->smarty->assign('default', 2, true);
$this->assertEquals("default 1", $this->smarty->fetch('test_template_function_003.tpl'), $text);
}
/** /**
@@ -348,6 +334,18 @@ class CompileFunctionTest extends PHPUnit_Smarty
array(true, 'cached call'), array(true, 'cached call'),
); );
} }
/**
* Function data provider
*/
public function functionProviderCachingValue()
{
return array(
array(false, 'normal compile',5,'15 215 5'),
array(false, 'normal call',3,'13 213 3'),
array(true, 'cached compile',6,'16 216 6'),
array(true, 'cached call',8,'16 218 8'),
);
}
/** /**
* Test spacings * Test spacings
* *

View File

@@ -1 +1 @@
{function name=functest default='default'}{$default} {counter start=1 nocache}{/function}{call name=functest} {function name=functestplugins}{counter start=$start1} {counter start=$start nocache}{/function}{call name=functestplugins start=2}{call name=functestplugins start=$start}