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
|
|
|
|
{
|
2013-05-30 19:00:00 +04:00
|
|
|
|
2013-07-29 14:58:14 +04:00
|
|
|
public function _testSandbox()
|
|
|
|
{
|
|
|
|
try {
|
2013-08-29 11:29:34 +04:00
|
|
|
var_dump($this->fenom->compileCode("{var \$a=12313}\nVar: {\$a}")->getBody());
|
2013-07-29 14:58:14 +04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
echo "$e";
|
|
|
|
}
|
|
|
|
exit;
|
|
|
|
}
|
2013-05-30 19:00:00 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerScalars
|
|
|
|
*/
|
2013-07-29 14:58:14 +04:00
|
|
|
public function testVar($tpl_val, $val)
|
|
|
|
{
|
2013-08-29 11:29:34 +04:00
|
|
|
$this->assertRender("{var \$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)
|
|
|
|
{
|
2013-08-29 11:29:34 +04:00
|
|
|
$this->assertRender("{var \$a}before {{$tpl_val}} after{/var}\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(
|
|
|
|
"{var \$a|low|dots}before {{$tpl_val}} after{/var}\nVar: {\$a}",
|
|
|
|
"Var: " . strtolower("before " . $val . " after") . "..."
|
|
|
|
);
|
2013-07-29 14:58:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testCycle()
|
|
|
|
{
|
|
|
|
$this->assertRender('{for $i=0 to=4}{cycle ["one", "two"]}, {/for}', "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(
|
|
|
|
'{var $a=["one", "two"]}{for $i=1 to=5}{cycle $a index=$i}, {/for}',
|
|
|
|
"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
|
|
|
}
|
|
|
|
|
|
|
|
}
|