mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Fix: cycle tag. Update comments. Add tests.
This commit is contained in:
@@ -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 "));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user