fenom/tests/cases/Fenom/TagsTest.php

67 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2013-06-28 11:53:53 +04:00
namespace Fenom;
2013-07-29 14:58:14 +04:00
class TagsTest extends TestCase
{
2015-01-07 15:24:57 +03:00
/**
* @group test-for
*/
public function testFor()
2013-07-29 14:58:14 +04:00
{
2015-01-07 15:24:57 +03:00
$this->assertRender('{for $i=0 to=3}{$i},{/for}', "0,1,2,3,");
2013-07-29 14:58:14 +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);
}
/**
* @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");
}
/**
* @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-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-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 "));
}
}