public function testGetSource() { $provider = new ArrayProvider(['test.htpl' => '{var}']); $htpl = new Htpl($provider); $htpl->assign('var', 'FooBar'); $expectedResult = '<?php echo htmlspecialchars($this->getVar(\'var\', $this->vars), ENT_QUOTES | ENT_SUBSTITUTE, \'utf-8\');?>'; $this->assertSame($expectedResult, trim($htpl->build('test.htpl')->getSource())); }
public function testDisplay() { $provider = new ArrayProvider(['test.htpl' => '{var}']); $htpl = new Htpl($provider); $htpl->assign('var', 'FooBar'); ob_start(); $htpl->build('test.htpl')->display(); $result = ob_get_clean(); $this->assertSame('FooBar', $result); }