add test for block plugin tag stack

This commit is contained in:
uwetews
2016-01-29 01:08:54 +01:00
parent dcb0d4be63
commit 39631cce4b
4 changed files with 62 additions and 0 deletions

View File

@@ -252,6 +252,18 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
$this->smarty->registerDefaultPluginHandler('my_block_plugin_handler');
$this->assertEquals('defaultblock hello world', $this->smarty->fetch('default2.tpl'));
}
/**
* test tag stack
*
* @run InSeparateProcess
* @preserveGlobalState disabled
*
*/
public function testBlockPluginTagStack()
{
$this->assertEquals('noop-teststack', $this->smarty->fetch('tag_stack.tpl'));
$this->assertEmpty($this->smarty->_cache['_tag_stack']);
}
/**
* Test caching

View File

@@ -0,0 +1,24 @@
<?php
/**
* Smarty plugin for testing block plugins
*
* @package Smarty
* @subpackage PHPunitPlugin
*/
/**
* Smarty {noop}{/noop} block plugin
*
* @param array $params parameter array
* @param string $content contents of the block
* @param object $template template object
* @param bool $repeat flag
*
* @return string content re-formatted
*/
function smarty_block_noop($params, $content, $template, &$repeat)
{
if (isset($content)) {
return $content;
}
}

View File

@@ -0,0 +1,25 @@
<?php
/**
* Smarty plugin for testing block plugins
*
* @package Smarty
* @subpackage PHPunitPlugin
*/
/**
* Smarty {teststack}{/teststack} block plugin
*
* @param array $params parameter array
* @param string $content contents of the block
* @param object $template template object
* @param bool $repeat flag
*
* @return string content re-formatted
*/
function smarty_block_teststack($params, $content, $template, &$repeat)
{
if (isset($content)) {
$stack = $template->smarty->_cache['_tag_stack'];
return $stack[0][0] . '-' . $stack[1][0];
}
}

View File

@@ -0,0 +1 @@
{noop}{teststack}{/teststack}{/noop}