Fix: cycle tag. Update comments. Add tests.

This commit is contained in:
bzick
2013-06-01 02:00:43 +04:00
parent 7453dbcf2b
commit f42d0cff5d
4 changed files with 66 additions and 37 deletions

View File

@@ -5,14 +5,14 @@ namespace Cytro;
class TagsTest extends TestCase {
// public function _testSandbox() {
// try {
// var_dump($this->cytro->compileCode(" literal: { \$a} end")->getBody());
// } catch(\Exception $e) {
// echo "$e";
// }
// exit;
// }
public function _testSandbox() {
try {
var_dump($this->cytro->compileCode('{for $i=0 to=5}{cycle ["one", "two"]}, {/for}')->getBody());
} catch(\Exception $e) {
echo "$e";
}
exit;
}
/**
* @dataProvider providerScalars
@@ -35,13 +35,22 @@ class TagsTest extends TestCase {
$this->assertRender("{var \$a|low|dots}before {{$tpl_val}} after{/var}\nVar: {\$a}", "\nVar: ".strtolower("before ".$val." after")."...");
}
public function testCycle() {
public function testCycle() {
$this->assertRender('{for $i=0 to=4}{cycle ["one", "two"]}, {/for}', "one, two, one, two, one, ");
}
/**
*
*/
public function testCycleIndex() {
$this->assertRender('{var $a=["one", "two"]}{for $i=1 to=5}{cycle $a index=$i}, {/for}', "two, one, two, one, two, ");
}
public function testFilter() {
/**
* @dataProvider providerScalars
*/
public function testFilter($tpl_val, $val) {
$this->assertRender("{filter|up} before {{$tpl_val}} after {/filter}", strtoupper(" before {$val} after "));
}
}