mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
1.3.1
This commit is contained in:
@ -56,6 +56,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
|
||||
$this->fenom = Fenom::factory(FENOM_RESOURCES . '/template', FENOM_RESOURCES . '/compile');
|
||||
$this->fenom->addModifier('dots', __CLASS__ . '::dots');
|
||||
$this->fenom->addModifier('concat', __CLASS__ . '::concat');
|
||||
$this->fenom->addModifier('append', __CLASS__ . '::append');
|
||||
$this->fenom->addFunction('test_function', __CLASS__ . '::inlineFunction');
|
||||
$this->fenom->addBlockFunction('test_block_function', __CLASS__ . '::blockFunction');
|
||||
}
|
||||
@ -70,6 +71,12 @@ class TestCase extends \PHPUnit_Framework_TestCase
|
||||
return call_user_func_array('var_export', func_get_args());
|
||||
}
|
||||
|
||||
public static function append()
|
||||
{
|
||||
return implode("", func_get_args());
|
||||
}
|
||||
|
||||
|
||||
public static function inlineFunction($params)
|
||||
{
|
||||
return isset($params["text"]) ? $params["text"] : "";
|
||||
|
@ -9,7 +9,7 @@ class TagsTest extends TestCase
|
||||
public function _testSandbox()
|
||||
{
|
||||
try {
|
||||
var_dump($this->fenom->compileCode('{var $a=Fenom\TestCase::dots("asd")}')->getBody());
|
||||
var_dump($this->fenom->compileCode("{var \$a=12313}\nVar: {\$a}")->getBody());
|
||||
} catch (\Exception $e) {
|
||||
echo "$e";
|
||||
}
|
||||
@ -21,7 +21,7 @@ class TagsTest extends TestCase
|
||||
*/
|
||||
public function testVar($tpl_val, $val)
|
||||
{
|
||||
$this->assertRender("{var \$a=$tpl_val}\nVar: {\$a}", "\nVar: " . $val);
|
||||
$this->assertRender("{var \$a=$tpl_val}\nVar: {\$a}", "Var: " . $val);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,7 +29,7 @@ class TagsTest extends TestCase
|
||||
*/
|
||||
public function testVarBlock($tpl_val, $val)
|
||||
{
|
||||
$this->assertRender("{var \$a}before {{$tpl_val}} after{/var}\nVar: {\$a}", "\nVar: before " . $val . " after");
|
||||
$this->assertRender("{var \$a}before {{$tpl_val}} after{/var}\nVar: {\$a}", "Var: before " . $val . " after");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -37,7 +37,7 @@ class TagsTest extends TestCase
|
||||
*/
|
||||
public function testVarBlockModified($tpl_val, $val)
|
||||
{
|
||||
$this->assertRender("{var \$a|low|dots}before {{$tpl_val}} after{/var}\nVar: {\$a}", "\nVar: " . strtolower("before " . $val . " after") . "...");
|
||||
$this->assertRender("{var \$a|low|dots}before {{$tpl_val}} after{/var}\nVar: {\$a}", "Var: " . strtolower("before " . $val . " after") . "...");
|
||||
}
|
||||
|
||||
public function testCycle()
|
||||
|
@ -708,6 +708,7 @@ class TemplateTest extends TestCase
|
||||
array('{$.server.one}', 'server1'),
|
||||
array('{$.const.PHP_EOL}', PHP_EOL),
|
||||
array('{$.version}', Fenom::VERSION),
|
||||
array('{"string"|append:"_":$.get.one}', 'string_get1'),
|
||||
|
||||
array('{$.get.one?}', '1'),
|
||||
array('{$.get.one is set}', '1'),
|
||||
@ -718,7 +719,7 @@ class TemplateTest extends TestCase
|
||||
public function _testSandbox()
|
||||
{
|
||||
try {
|
||||
var_dump($this->fenom->compileCode('{$.const.access?}')->getBody());
|
||||
var_dump($this->fenom->compileCode('{"string"|append:$.get.one}')->getBody());
|
||||
} catch (\Exception $e) {
|
||||
print_r($e->getMessage() . "\n" . $e->getTraceAsString());
|
||||
}
|
||||
|
Reference in New Issue
Block a user