mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
add {break} and {continue} tests
This commit is contained in:
@@ -269,4 +269,40 @@ class CompileForeachTest extends PHPUnit_Smarty
|
|||||||
$this->assertEquals("outer=0#0-9inner=1#0-4inner=2#0-10##outer=1#1-8inner=1#1-4inner=2#1-10#####hallo",
|
$this->assertEquals("outer=0#0-9inner=1#0-4inner=2#0-10##outer=1#1-8inner=1#1-4inner=2#1-10#####hallo",
|
||||||
$this->smarty->fetch('028_foreach.tpl'));
|
$this->smarty->fetch('028_foreach.tpl'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testForeachBreak_29()
|
||||||
|
{
|
||||||
|
$this->assertEquals("12",
|
||||||
|
$this->smarty->fetch('029_foreach.tpl'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testForeachBreak_30()
|
||||||
|
{
|
||||||
|
$this->assertEquals("a1a2b1b2",
|
||||||
|
$this->smarty->fetch('030_foreach.tpl'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testForeachBreak_31()
|
||||||
|
{
|
||||||
|
$this->assertEquals("a1a2",
|
||||||
|
$this->smarty->fetch('031_foreach.tpl'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testForeachContinue_32()
|
||||||
|
{
|
||||||
|
$this->assertEquals("1245",
|
||||||
|
$this->smarty->fetch('032_foreach.tpl'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testForeachContinue_33()
|
||||||
|
{
|
||||||
|
$this->assertEquals("a1a2a4a5b1b2b4b5",
|
||||||
|
$this->smarty->fetch('033_foreach.tpl'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testForeachContinue_34()
|
||||||
|
{
|
||||||
|
$this->assertEquals("a1a2b1b2",
|
||||||
|
$this->smarty->fetch('034_foreach.tpl'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,5 @@
|
|||||||
|
{strip}
|
||||||
|
{foreach [1,2,3,4,5] as $i}
|
||||||
|
{if $i == 3}{break}{/if}
|
||||||
|
{$i}
|
||||||
|
{/foreach}
|
@@ -0,0 +1,7 @@
|
|||||||
|
{strip}
|
||||||
|
{foreach ['a','b'] as $a}
|
||||||
|
{foreach [1,2,3,4,5] as $i}
|
||||||
|
{if $i == 3}{break}{/if}
|
||||||
|
{$a}{$i}
|
||||||
|
{/foreach}
|
||||||
|
{/foreach}
|
@@ -0,0 +1,7 @@
|
|||||||
|
{strip}
|
||||||
|
{foreach ['a','b'] as $a}
|
||||||
|
{foreach [1,2,3,4,5] as $i}
|
||||||
|
{if $i == 3}{break 2}{/if}
|
||||||
|
{$a}{$i}
|
||||||
|
{/foreach}
|
||||||
|
{/foreach}
|
@@ -0,0 +1,5 @@
|
|||||||
|
{strip}
|
||||||
|
{foreach [1,2,3,4,5] as $i}
|
||||||
|
{if $i == 3}{continue}{/if}
|
||||||
|
{$i}
|
||||||
|
{/foreach}
|
@@ -0,0 +1,7 @@
|
|||||||
|
{strip}
|
||||||
|
{foreach ['a','b'] as $a}
|
||||||
|
{foreach [1,2,3,4,5] as $i}
|
||||||
|
{if $i == 3}{continue}{/if}
|
||||||
|
{$a}{$i}
|
||||||
|
{/foreach}
|
||||||
|
{/foreach}
|
@@ -0,0 +1,7 @@
|
|||||||
|
{strip}
|
||||||
|
{foreach ['a','b'] as $a}
|
||||||
|
{foreach [1,2,3,4,5] as $i}
|
||||||
|
{if $i == 3}{continue 2}{/if}
|
||||||
|
{$a}{$i}
|
||||||
|
{/foreach}
|
||||||
|
{/foreach}
|
Reference in New Issue
Block a user