* @author Kornel LesiƄski * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License * @version SVN: $Id: EchoExecuteTest.php 584 2009-04-27 11:45:25Z kornel $ * @link http://phptal.org/ */ require_once dirname(__FILE__)."/config.php"; class EchoExecuteTest extends PHPTAL_TestCase { private function echoExecute(PHPTAL $tpl) { try { ob_start(); $this->assertEquals(0,strlen($tpl->echoExecute())); $res = ob_get_clean(); } catch(Exception $e) { ob_end_clean(); throw $e; } $res2 = $tpl->execute(); $res3 = $tpl->execute(); $this->assertEquals($res2,$res3,"Multiple runs should give same result"); $this->assertEquals($res2,$res,"Execution with and without buffering should give same result"); return trim_string($res); } function testEchoExecute() { $tpl = $this->newPHPTAL(); $tpl->setSource(''); $this->assertEquals("",$this->echoExecute($tpl)); } function testEchoExecuteDecls() { $tpl = $this->newPHPTAL(); $tpl->setSource(''); $this->assertEquals(trim_string(''),$this->echoExecute($tpl)); } function testEchoExecuteDeclsMacro() { try { $tpl = $this->newPHPTAL(); $tpl->setSource('test'); $this->assertEquals(trim_string('test'),$this->echoExecute($tpl)); } catch(PHPTAL_ConfigurationException $e) { // this is fine. Combination of macros and echoExecute is not supported yet (if it were, the test above is valid) $this->assertContains("echoExecute",$e->getMessage()); } } }