Update docs and add tests

This commit is contained in:
bzick
2013-07-23 11:32:31 +04:00
parent a5f83a59b8
commit e37c8468eb
5 changed files with 44 additions and 11 deletions

View File

@@ -5,6 +5,19 @@ use Fenom\Render,
class FenomTest extends \Fenom\TestCase {
public static function providerOptions() {
return array(
array("disable_methods", Fenom::DENY_METHODS),
array("disable_native_funcs", Fenom::DENY_INLINE_FUNCS),
array("disable_cache", Fenom::DISABLE_CACHE),
array("force_compile", Fenom::FORCE_COMPILE),
array("auto_reload", Fenom::AUTO_RELOAD),
array("force_include", Fenom::FORCE_INCLUDE),
array("auto_escape", Fenom::AUTO_ESCAPE),
array("force_verify", Fenom::FORCE_VERIFY)
);
}
public function testCompileFile() {
$a = array(
"a" => "a",
@@ -22,10 +35,6 @@ class FenomTest extends \Fenom\TestCase {
public function testStorage() {
$this->tpl('custom.tpl', 'Custom template');
$this->assertSame("Custom template", $this->fenom->fetch('custom.tpl', array()));
//$this->fenom->clearCompiledTemplate('custom.tpl', false);
//$this->assertSame("Custom template", $this->fenom->fetch('custom.tpl', array()));
$this->tpl('custom.tpl', 'Custom template 2');
$this->assertSame("Custom template", $this->fenom->fetch('custom.tpl', array()));
}
@@ -78,6 +87,21 @@ class FenomTest extends \Fenom\TestCase {
$this->tpl('custom.tpl', 'Custom compiler {myblockcompiler name="bar"} block1 {tag name="baz"} block2 {/myblockcompiler}');
$this->assertSame("Custom compiler PHP_VERSION: ".PHP_VERSION." (for bar) block1 Tag baz of compiler block2 End of compiler", $this->fenom->fetch('custom.tpl', array()));
}
}
?>
/**
* @dataProvider providerOptions
*/
public function testOptions($code, $option) {
static $options = array();
static $flags = 0;
$options[$code] = true;
$flags |= $option;
$this->fenom->setOptions($options);
$this->assertSame($this->fenom->getOptions(), $flags);
// printf("from %010b, flags %010b\n", $this->fenom->getOptions(), $flags);
// $this->fenom->setOptions(array($code => false));
// printf("remove %010b from option %010b, flags %010b\n", $option, $this->fenom->getOptions(), $flags & ~$option);
// $this->assertSame($this->fenom->getOptions(), $flags & ~$option);
}
}