* @author Kornel LesiƄski * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License * @version SVN: $Id: AttributesInterpolationTest.php 998 2010-10-23 13:26:47Z kornel $ * @link http://phptal.org/ */ class AttributesInterpolationTest extends PHPTAL_TestCase { public function testInterpol() { $src = << EOT; $exp = << EOT; $tpl = $this->newPHPTAL(); $tpl->setSource($src); $tpl->foo = 'foo value'; $res = $tpl->execute(); $this->assertEquals($exp, $res); } public function testInterpol2() { $src = << EOT; $exp = << EOT; $tpl = $this->newPHPTAL(); $tpl->setSource($src); $tpl->foo = 'foo value'; $tpl->foo2 = '{foo2 }'; $res = $tpl->execute(); $this->assertEquals($exp, $res); } public function testInterpol3() { $src = << EOT; $exp = << EOT; $tpl = $this->newPHPTAL(); $tpl->setSource($src); $tpl->foo = 'foo value'; $res = $tpl->execute(); $this->assertEquals($exp, $res); } public function testInterpol3a() { $src = << EOT; $exp = << EOT; $tpl = $this->newPHPTAL()->setSource($src); $tpl->foo = 'foo value'; $res = $tpl->execute(); $this->assertEquals($exp, $res); } public function testInterpol3b() { $src = << EOT; $exp = << EOT; $tpl = $this->newPHPTAL()->setSource($src); $tpl->foo = 'foo value'; $res = $tpl->execute(); $this->assertEquals($exp, $res); } public function testNoInterpol() { $src = << EOT; $exp = << EOT; $tpl = $this->newPHPTAL(); $tpl->setSource($src); $tpl->foo = 'foo value'; $res = $tpl->execute(); $this->assertEquals($exp, $res); } public function testInterpolAdv() { $src = << EOT; $exp = << EOT; $tpl = $this->newPHPTAL(); $tpl->setSource($src); $tpl->foo = 'foo value'; $res = $tpl->execute(); $this->assertEquals($exp, $res); } public function testPHPBlock() { $tpl = $this->newPHPTAL(); $tpl->setSource('

"; ?>testtest\'/>'); $this->assertEquals('

', $tpl->execute()); } public function testPHPBlockShort() { ini_set('short_open_tag', 1); if (!ini_get('short_open_tag')) $this->markTestSkipped("PHP is buggy"); $tpl = $this->newPHPTAL(); $tpl->setSource('

"); ?>testtest\'/>'); $this->assertEquals('

', $tpl->execute()); ini_restore('short_open_tag'); } public function testPHPBlockNoShort() { ini_set('short_open_tag', 0); if (ini_get('short_open_tag')) $this->markTestSkipped("PHP is buggy"); $tpl = $this->newPHPTAL(); $tpl->setSource('

"); ?>testtest\'/>'); try { $this->assertEquals(normalize_html('

'), normalize_html($tpl->execute())); } catch(PHPTAL_ParserException $e) {/* xml ill-formedness error is ok too */} ini_restore('short_open_tag'); } }