mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
add test for block plugin tag stack
This commit is contained in:
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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];
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
{noop}{teststack}{/teststack}{/noop}
|
Reference in New Issue
Block a user