* @author Kornel LesiƄski * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License * @version SVN: $Id: DoctypeTest.php 922 2010-06-20 21:28:42Z kornel $ * @link http://phptal.org/ */ class DoctypeTest extends PHPTAL_TestCase { function testSimple() { $tpl = $this->newPHPTAL('input/doctype.01.html'); $res = $tpl->execute(); $res = normalize_html($res); $exp = normalize_html_file('output/doctype.01.html'); $this->assertEquals($exp, $res); } function testPreservesNewlineAfterDoctype() { $src = "\n\n\n"; $tpl = $this->newPHPTAL()->setSource($src); $this->assertEquals($src,$tpl->execute()); $src = "\n"; $tpl->setSource($src); $this->assertEquals($src,$tpl->execute()); } function testMacro() { $tpl = $this->newPHPTAL('input/doctype.02.user.html'); $res = $tpl->execute(); $res = normalize_html($res); $exp = normalize_html_file('output/doctype.02.html'); $this->assertEquals($exp, $res); } function testDeepMacro() { $tpl = $this->newPHPTAL('input/doctype.03.html'); $res = $tpl->execute(); $res = normalize_html($res); $exp = normalize_html_file('output/doctype.03.html'); $this->assertEquals($exp, $res); } function testDtdInline() { $tpl = $this->newPHPTAL('input/doctype.04.html'); $res = $tpl->execute(); $res = normalize_html($res); $exp = normalize_html_file('output/doctype.04.html'); $this->assertEquals($exp, $res); } function testClearedOnReexecution() { $tpl = $this->newPHPTAL(); $tpl->setSource(''); $this->assertContains("DOCTYPE html PUBLIC", $tpl->execute()); $this->assertContains("DOCTYPE html PUBLIC", $tpl->execute()); $tpl->setSource(''); $this->assertNotContains("DOCTYPE html PUBLIC", $tpl->execute()); $this->assertNotContains("DOCTYPE html PUBLIC", $tpl->execute()); } /** * this is pretty crazy case of PHPTAL being reused while template is still being executed */ function testClearedOnNestedReexecution() { $tpl = $this->newPHPTAL(); $tpl->tpl = $tpl; $tpl->setSource(' '); $this->assertEquals(normalize_html(''), normalize_html($tpl->execute())); } }