Add STRIP option

This commit is contained in:
bzick
2014-05-08 12:56:37 +04:00
parent 83e02ebbe9
commit 45afbfabdf
12 changed files with 209 additions and 87 deletions

View File

@ -11,18 +11,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
*/
public $fenom;
public $values = array(
"zero" => 0,
"one" => 1,
"two" => 2,
"three" => 3,
"float" => 4.5,
"bool" => true,
0 => "empty value",
1 => "one value",
2 => "two value",
3 => "three value",
);
public $values;
public static function getVars()
{
@ -40,6 +29,12 @@ class TestCase extends \PHPUnit_Framework_TestCase
"b" => 2,
"two" => 2
),
"num" => array(
1 => "one",
2 => "two",
3 => "three",
4 => "four"
),
0 => "empty value",
1 => "one value",
2 => "two value",
@ -62,6 +57,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
$this->fenom->addModifier('append', __CLASS__ . '::append');
$this->fenom->addFunction('test_function', __CLASS__ . '::inlineFunction');
$this->fenom->addBlockFunction('test_block_function', __CLASS__ . '::blockFunction');
$this->values = $this->getVars();
}
public static function dots($value)

View File

@ -185,7 +185,7 @@ class TemplateTest extends TestCase
'Mod: {$lorem|str_rot13}!',
'Fenom\Error\CompileException',
"Modifier str_rot13 not found",
Fenom::DENY_INLINE_FUNCS
Fenom::DENY_NATIVE_FUNCS
),
array('Mod: {$lorem|my_encode}!', 'Fenom\Error\CompileException', "Modifier my_encode not found"),
array('Mod: {$lorem|truncate:}!', 'Fenom\Error\CompileException', "Unexpected end of expression"),

View File

@ -13,7 +13,8 @@ class FenomTest extends \Fenom\TestCase
array("auto_reload", Fenom::AUTO_RELOAD),
array("force_include", Fenom::FORCE_INCLUDE),
array("auto_escape", Fenom::AUTO_ESCAPE),
array("force_verify", Fenom::FORCE_VERIFY)
array("force_verify", Fenom::FORCE_VERIFY),
array("strip", Fenom::AUTO_STRIP),
);
}
@ -289,6 +290,19 @@ class FenomTest extends \Fenom\TestCase
);
$this->assertSame(3, $iteration);
}
/**
* @group strip
*/
public function testStrip() {
$this->fenom->setOptions(Fenom::AUTO_STRIP);
$tpl = <<<TPL
<div class="item item-one">
<a href="/item/{\$one}">number {\$num.1}</a>
</div>
TPL;
$this->assertRender($tpl, '<div class="item item-one"><a href="/item/1">number one</a></div>');
}
}