{
    public function load($template, $renderer = 'php')
    {
        return new sfTemplateStorageString($template, 'foo');
    }
    public function compile($template)
    {
        return 'COMPILED';
    }
}
class FooTemplateRenderer extends sfTemplateRenderer
{
    public function evaluate(sfTemplateStorage $template, array $parameters = array())
    {
        return 'foo';
    }
}
$t->diag('compilable templates');
$engine = new ProjectTemplateEngine(new CompilableTemplateLoader(), array('foo' => new FooTemplateRenderer()));
$t->is($engine->render('index'), 'foo', '->load() takes into account the renderer embedded in the sfTemplateStorage instance if not null');
// ->escape()
$t->diag('->escape()');
$engine = new ProjectTemplateEngine($loader);
$t->is($engine->escape('<br />'), '&lt;br /&gt;', '->escape() escapes strings');
$t->is($engine->escape($foo = new stdClass()), $foo, '->escape() does nothing on non strings');
// ->getCharset() ->setCharset()
$t->diag('->getCharset() ->setCharset()');
$engine = new ProjectTemplateEngine($loader);
$t->is($engine->getCharset(), 'UTF-8', '->getCharset() returns UTF-8 by default');
$engine->setCharset('ISO-8859-1');
$t->is($engine->getCharset(), 'ISO-8859-1', '->setCharset() changes the default charset to use');
示例#2
0
 public function testGetLoader()
 {
     $engine = new ProjectTemplateEngine(new ehough_templating_TemplateNameParser(), $this->loader);
     $this->assertSame($this->loader, $engine->getLoader());
 }