add {break} test

This commit is contained in:
uwetews
2016-02-01 20:23:25 +01:00
parent 33bdb44723
commit c48e16c5fe
4 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?php
/**
* Smarty PHPunit tests compilation of {break} tag
*
* @package PHPunit
* @author Uwe Tews
*/
/**
* class for {break} tag tests
*
* @runTestsInSeparateProcess
* @preserveGlobalState disabled
* @backupStaticAttributes enabled
*/
class CompileBreakTest extends PHPUnit_Smarty
{
public function setUp()
{
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
{
$this->cleanDirs();
}
/**
* test {break} in foreach
*/
public function testBreakForeach()
{
$this->smarty->assign('array', array(1,2,3));
$this->assertEquals('1', $this->smarty->fetch('break_foreach.tpl'));
}
/**
* test {break} in foreach nocache
*/
public function testBreakForeachNocache()
{
$this->smarty->assign('array', array(1,2,3), true);
$this->smarty->caching = true;
$this->assertEquals('1', $this->smarty->fetch('break_foreach.tpl'));
}
}

View File

@@ -0,0 +1,7 @@
{strip}
{foreach $array as $key => $i}
{if $key == 1}
{break}
{/if}
{$i}
{/foreach}