add_sub_block($subTpl); } public function testsimpleVar(){ $tpl = new TplBlock(); $tpl->add_vars(array( "name" => "Gnieark", "title" => "Monsieur", "firstname" => "Grouik" ) ); $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 have to be shown WONT to be shown "; $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)); } }