OK
');
$res = normalize_html($tpl->execute());
$this->assertEquals('
', $res, $tpl->getCodePath());
}
function testBlock()
{
$tpl = $this->newPHPTAL('input/metal-slot.03.html');
$res = normalize_html($tpl->execute());
$exp = normalize_html_file('output/metal-slot.03.html');
$this->assertEquals($exp, $res);
}
function testFillAndCondition()
{
$tpl = $this->newPHPTAL('input/metal-slot.04.html');
$tpl->fillit = true;
$res = normalize_html($tpl->execute());
$exp = normalize_html_file('output/metal-slot.04.html');
$this->assertEquals($exp, $res);
}
function testFillWithi18n()
{
$tpl = $this->newPHPTAL();
$tpl->setSource('
');
$tr = new DummyTranslator();
$tr->setTranslation("translateme", "translatedyou");
$tr->setTranslation("translatemetoo", "translatedyouaswell");
$tpl->setTranslator($tr);
$this->assertEquals(normalize_html('
'), normalize_html($tpl->execute()), $tpl->getCodePath());
}
/**
* this is violation of TAL specification, but needs to work for backwards compatibility
*/
function testFillPreservedAcrossCalls()
{
$tpl = $this->newPHPTAL();
$tpl->setSource('
foocontent');
$tpl->execute();
$tpl->setSource('
FAIL');
$this->assertEquals('foocontent', $tpl->execute());
}
/**
* this is violation of TAL specification, but needs to work for backwards compatibility
*/
function testFillPreservedAcrossCalls2()
{
$tpl = $this->newPHPTAL();
$tpl->setSource('
foocontent
');
$tpl->execute();
$tpl->setSource('
FAIL
');
$this->assertEquals('
foocontent
', $tpl->execute());
}
function testUsesCallbackForLargeSlots()
{
$tpl = $this->newPHPTAL();
$tpl->setSource('
stuff
stuff
stuff
');
$res = $tpl->execute();
$this->assertGreaterThan(PHPTAL_Php_Attribute_METAL_FillSlot::CALLBACK_THRESHOLD, strlen($res));
$tpl_php_source = file_get_contents($tpl->getCodePath());
$this->assertNotContains("fillSlot(", $tpl_php_source);
$this->assertContains("fillSlotCallback(", $tpl_php_source);
}
function testUsesBufferForSmallSlots()
{
$tpl = $this->newPHPTAL();
$tpl->setSource('
stuff lots of stuff stuff lots of stuff stuff lots of stuff stuff lots of stuff stuff lots of stuff stuff lots of stuff
');
$tpl->execute();
$tpl_php_source = file_get_contents($tpl->getCodePath());
$this->assertNotContains("fillSlotCallback(", $tpl_php_source);
$this->assertContains("fillSlot(", $tpl_php_source);
}
function testSlotBug()
{
$tpl = $this->newPHPTAL()->setSource(<<
OK subpage filled page/valuebis
page/value:FAIL unfilled page/value
page/valuebis:FAIL unfilled page/valuebis
FAIL unused invalid subpage/valuebis
OK toplevel-filled page/value
HTML
);
$this->assertEquals(
normalize_html('