* @author Kornel LesiƄski * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License * @version SVN: $Id: $ * @link http://phptal.org/ */ 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 normalize_html($res); } function testEchoExecute() { $tpl = $this->newPHPTAL(); $tpl->setSource(''); $this->assertEquals("", $this->echoExecute($tpl)); } function testEchoExecuteDecls() { $tpl = $this->newPHPTAL(); $tpl->setSource(''); $this->assertEquals(normalize_html(''), $this->echoExecute($tpl)); } function testEchoExecuteDeclsMacro() { try { $tpl = $this->newPHPTAL(); $tpl->setSource('test'); $this->assertEquals(normalize_html('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()); } } }