Update section tests

This commit is contained in:
Uwe Tews
2015-07-29 23:28:57 +02:00
parent 63b3f4c522
commit cf2b0c8aed
7 changed files with 12 additions and 7 deletions

View File

@@ -28,38 +28,37 @@ class CompileSectionTest extends PHPUnit_Smarty
*/ */
public function testSection1() public function testSection1()
{ {
$tpl = $this->smarty->createTemplate('eval:{assign var=foo value=[0,1,2,3,4,5,6,7,8,9]}{section name=bar loop=$foo}{$foo[bar]}{/section}'); $tpl = $this->smarty->createTemplate('section1.tpl');
$this->assertEquals("0123456789", $this->smarty->fetch($tpl)); $this->assertEquals("0123456789", $this->smarty->fetch($tpl));
} }
public function testSection2() public function testSection2()
{ {
$tpl = $this->smarty->createTemplate('eval:{assign var=foo value=[0,1,2,3,4,5,6,7,8,9]}{section name=bar loop=$foo}{$foo[bar]}{sectionelse} else {/section}'); $tpl = $this->smarty->createTemplate('section2.tpl');
$this->assertEquals("0123456789", $this->smarty->fetch($tpl)); $this->assertEquals("0123456789", $this->smarty->fetch($tpl));
} }
public function testSection3() public function testSection3()
{ {
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); $tpl = $this->smarty->createTemplate('section3.tpl');
$tpl = $this->smarty->createTemplate('eval:{section name=bar loop=$foo}{$foo[bar]}{sectionelse}else{/section}');
$this->assertEquals("else", $this->smarty->fetch($tpl)); $this->assertEquals("else", $this->smarty->fetch($tpl));
} }
public function testSection4() public function testSection4()
{ {
$tpl = $this->smarty->createTemplate('eval:{assign var=foo value=[0,1,2,3,4,5,6,7,8,9]}{section name=bar loop=$foo}{$foo[bar]}{sectionelse} else {/section}'); $tpl = $this->smarty->createTemplate('section4.tpl');
$this->assertEquals("0123456789", $this->smarty->fetch($tpl)); $this->assertEquals("0123456789", $this->smarty->fetch($tpl));
} }
public function testSection6() public function testSection6()
{ {
$tpl = $this->smarty->createTemplate('eval:{assign var=foo value=[0,1,2,3,4,5,6,7,8,9]}{section name=bar loop=$foo}{$foo[bar]}{sectionelse} else {/section}total{$smarty.section.bar.total}'); $tpl = $this->smarty->createTemplate('section6.tpl');
$this->assertEquals("0123456789total10", $this->smarty->fetch($tpl)); $this->assertEquals("0123456789total10", $this->smarty->fetch($tpl));
} }
public function testSection7() public function testSection7()
{ {
$tpl = $this->smarty->createTemplate('eval:{assign var=foo value=[0,1,2,3,4,5,6,7,8,9]}{section name=bar loop=$foo}{$smarty.section.bar.index}{$smarty.section.bar.iteration}{sectionelse} else {/section}'); $tpl = $this->smarty->createTemplate('section7.tpl');
$this->assertEquals("011223344556677889910", $this->smarty->fetch($tpl)); $this->assertEquals("011223344556677889910", $this->smarty->fetch($tpl));
} }
} }

View File

@@ -0,0 +1 @@
{assign var=foo value=[0,1,2,3,4,5,6,7,8,9]}{section name=bar loop=$foo}{$foo[bar]}{/section}

View File

@@ -0,0 +1 @@
{assign var=foo value=[0,1,2,3,4,5,6,7,8,9]}{section name=bar loop=$foo start=$i}{$foo[bar]}{sectionelse} else {/section}

View File

@@ -0,0 +1 @@
{section name=bar loop=$foo}{$foo[bar]}{sectionelse}else{/section}

View File

@@ -0,0 +1 @@
{assign var=foo value=[0,1,2,3,4,5,6,7,8,9]}{section name=bar loop=$foo}{$foo[bar]}{sectionelse} else {/section}

View File

@@ -0,0 +1 @@
{assign var=foo value=[0,1,2,3,4,5,6,7,8,9]}{section name=bar loop=$foo}{$foo[bar]}{sectionelse} else {/section}total{$smarty.section.bar.total}

View File

@@ -0,0 +1 @@
{assign var=foo value=[0,1,2,3,4,5,6,7,8,9]}{section name=bar loop=$foo}{$smarty.section.bar.index}{$smarty.section.bar.iteration}{sectionelse} else {/section}