improve unit tests

This commit is contained in:
Gnieark 2018-03-20 19:03:06 +01:00
parent b2281f4c77
commit a121d1974d
2 changed files with 32 additions and 0 deletions

1
temp.txt Normal file
View File

@ -0,0 +1 @@
Hello {{name}}

View File

@ -23,5 +23,36 @@ class TplBlockTest extends TestCase{
);
$this->assertEquals("Hello Gnieark", $tpl->apply_tpl_str("Hello {{name}}"));
}
//test from a file
public function testParseFromFile(){
file_put_contents("temp.txt","Hello {{name}}");
$tpl = new TplBlock();
$tpl->add_vars(array(
"name" => "Gnieark",
"title" => "Monsieur",
"firstname" => "Grouik"
)
);
$this->assertEquals("Hello Gnieark", $tpl->apply_tpl_file("temp.txt"));
}
//test blocs
public function testBlocs(){
$str = "
Bhah blah wpooie456
<!-- BEGIN bloc -->
have to be shown
<!-- END bloc -->
<!-- BEGIN blocTwo -->
WONT to be shown
<!-- END blocTwo -->
";
$tpl = new TplBlock();
$tpl2 = new TplBlock("bloc");
$tpl->add_sub_block($tpl2);
$str = $tpl->apply_tpl_str($str);
$this->assertContains('have',$str);
$this->assertFalse(strpos("WONT",$str));
}
}