2013-05-30 19:00:00 +04:00
|
|
|
<?php
|
|
|
|
|
2013-06-28 11:53:53 +04:00
|
|
|
namespace Fenom;
|
2013-05-30 19:00:00 +04:00
|
|
|
|
|
|
|
|
2013-07-29 14:58:14 +04:00
|
|
|
class TagsTest extends TestCase
|
|
|
|
{
|
2015-01-07 15:24:57 +03:00
|
|
|
/**
|
|
|
|
* @group test-for
|
|
|
|
*/
|
2015-02-22 23:07:26 +03:00
|
|
|
// public function testFor()
|
|
|
|
// {
|
|
|
|
// $this->assertRender('{for $i=0 to=3}{$i},{/for}', "0,1,2,3,");
|
|
|
|
// }
|
2013-05-30 19:00:00 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerScalars
|
|
|
|
*/
|
2013-07-29 14:58:14 +04:00
|
|
|
public function testVar($tpl_val, $val)
|
|
|
|
{
|
2015-02-22 23:07:26 +03:00
|
|
|
$this->assertRender("{set \$a=$tpl_val}\nVar: {\$a}", "Var: " . $val);
|
2013-05-30 19:00:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerScalars
|
|
|
|
*/
|
2013-07-29 14:58:14 +04:00
|
|
|
public function testVarBlock($tpl_val, $val)
|
|
|
|
{
|
2015-02-22 23:07:26 +03:00
|
|
|
$this->assertRender("{set \$a}before {{$tpl_val}} after{/set}\nVar: {\$a}", "Var: before " . $val . " after");
|
2013-05-30 19:00:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerScalars
|
|
|
|
*/
|
2013-07-29 14:58:14 +04:00
|
|
|
public function testVarBlockModified($tpl_val, $val)
|
|
|
|
{
|
2014-05-06 14:22:58 +04:00
|
|
|
$this->assertRender(
|
2015-02-22 23:07:26 +03:00
|
|
|
"{set \$a|low|dots}before {{$tpl_val}} after{/set}\nVar: {\$a}",
|
2014-05-06 14:22:58 +04:00
|
|
|
"Var: " . strtolower("before " . $val . " after") . "..."
|
|
|
|
);
|
2013-07-29 14:58:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testCycle()
|
|
|
|
{
|
2015-02-22 23:07:26 +03:00
|
|
|
$this->assertRender('{foreach 0..4 as $i}{cycle ["one", "two"]}, {/foreach}', "one, two, one, two, one, ");
|
2013-05-30 19:00:00 +04:00
|
|
|
}
|
|
|
|
|
2013-07-29 14:58:14 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function testCycleIndex()
|
|
|
|
{
|
2014-05-06 14:22:58 +04:00
|
|
|
$this->assertRender(
|
2015-02-22 23:07:26 +03:00
|
|
|
'{set $a=["one", "two"]}{foreach 1..5 as $i}{cycle $a index=$i}, {/foreach}',
|
2014-05-06 14:22:58 +04:00
|
|
|
"two, one, two, one, two, "
|
|
|
|
);
|
2013-05-30 19:00:00 +04:00
|
|
|
}
|
|
|
|
|
2013-07-29 14:58:14 +04:00
|
|
|
/**
|
|
|
|
* @dataProvider providerScalars
|
|
|
|
*/
|
|
|
|
public function testFilter($tpl_val, $val)
|
|
|
|
{
|
|
|
|
$this->assertRender("{filter|up} before {{$tpl_val}} after {/filter}", strtoupper(" before {$val} after "));
|
2013-05-30 19:00:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|