From 33bdb44723c049341e977f584350fdada52da600 Mon Sep 17 00:00:00 2001 From: uwetews Date: Fri, 29 Jan 2016 02:33:40 +0100 Subject: [PATCH] add {break} and {continue} tests --- .../TagTests/Foreach/CompileForeachTest.php | 36 +++++++++++++++++++ .../Foreach/templates/029_foreach.tpl | 5 +++ .../Foreach/templates/030_foreach.tpl | 7 ++++ .../Foreach/templates/031_foreach.tpl | 7 ++++ .../Foreach/templates/032_foreach.tpl | 5 +++ .../Foreach/templates/033_foreach.tpl | 7 ++++ .../Foreach/templates/034_foreach.tpl | 7 ++++ 7 files changed, 74 insertions(+) create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/029_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/030_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/031_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/032_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/033_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/Foreach/templates/034_foreach.tpl diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php b/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php index 7127a3df..48833946 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php @@ -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->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')); + } } diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/029_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/029_foreach.tpl new file mode 100644 index 00000000..afae1b27 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/029_foreach.tpl @@ -0,0 +1,5 @@ +{strip} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{break}{/if} + {$i} +{/foreach} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/030_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/030_foreach.tpl new file mode 100644 index 00000000..70b9f038 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/030_foreach.tpl @@ -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} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/031_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/031_foreach.tpl new file mode 100644 index 00000000..e19b1f8b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/031_foreach.tpl @@ -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} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/032_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/032_foreach.tpl new file mode 100644 index 00000000..c0bae38b --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/032_foreach.tpl @@ -0,0 +1,5 @@ +{strip} +{foreach [1,2,3,4,5] as $i} + {if $i == 3}{continue}{/if} + {$i} +{/foreach} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/033_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/033_foreach.tpl new file mode 100644 index 00000000..1a3509a9 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/033_foreach.tpl @@ -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} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/034_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/034_foreach.tpl new file mode 100644 index 00000000..ee2031bb --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/templates/034_foreach.tpl @@ -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} \ No newline at end of file