From c48e16c5fe7989e3aba39d6d348673d3146ec935 Mon Sep 17 00:00:00 2001 From: uwetews Date: Mon, 1 Feb 2016 20:23:25 +0100 Subject: [PATCH] add {break} test --- .../TagTests/break/CompileBreakTest.php | 45 +++++++++++++++++++ .../TagTests/break/cache/dummy.txt | 0 .../break/templates/break_foreach.tpl | 7 +++ .../TagTests/break/templates_c/dummy.txt | 0 4 files changed, 52 insertions(+) create mode 100644 tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/break/cache/dummy.txt create mode 100644 tests/UnitTests/TemplateSource/TagTests/break/templates/break_foreach.tpl create mode 100644 tests/UnitTests/TemplateSource/TagTests/break/templates_c/dummy.txt diff --git a/tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php b/tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php new file mode 100644 index 00000000..7594678a --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php @@ -0,0 +1,45 @@ +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')); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/break/cache/dummy.txt b/tests/UnitTests/TemplateSource/TagTests/break/cache/dummy.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/UnitTests/TemplateSource/TagTests/break/templates/break_foreach.tpl b/tests/UnitTests/TemplateSource/TagTests/break/templates/break_foreach.tpl new file mode 100644 index 00000000..b289e535 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/break/templates/break_foreach.tpl @@ -0,0 +1,7 @@ +{strip} +{foreach $array as $key => $i} + {if $key == 1} + {break} + {/if} + {$i} +{/foreach} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/break/templates_c/dummy.txt b/tests/UnitTests/TemplateSource/TagTests/break/templates_c/dummy.txt new file mode 100644 index 00000000..e69de29b