fix handling of a default 'template' as a string
This commit is contained in:
parent
6dbd1e102b
commit
9d1004b59e
|
@ -99,7 +99,11 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
|||
private function templateExists($template)
|
||||
{
|
||||
if ($this->templating instanceof EngineInterface) {
|
||||
return $this->templating->exists($template);
|
||||
try {
|
||||
return $this->templating->exists($template);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$loader = $this->templating->getLoader();
|
||||
|
|
|
@ -50,7 +50,7 @@ class HIncludeFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals('<hx:include src="/foo"></hx:include>', $strategy->render('/foo', Request::create('/'))->getContent());
|
||||
}
|
||||
|
||||
public function testRenderWhithDefault()
|
||||
public function testRenderWithDefault()
|
||||
{
|
||||
// only default
|
||||
$strategy = new HIncludeFragmentRenderer();
|
||||
|
@ -64,4 +64,17 @@ class HIncludeFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
|||
$strategy = new HIncludeFragmentRenderer(null, null, 'global_default');
|
||||
$this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent());
|
||||
}
|
||||
}
|
||||
|
||||
public function testRenderWithDefaultText()
|
||||
{
|
||||
$engine = $this->getMock('Symfony\\Component\\Templating\\EngineInterface');
|
||||
$engine->expects($this->once())
|
||||
->method('exists')
|
||||
->with('default')
|
||||
->will($this->throwException(new \InvalidArgumentException()));
|
||||
|
||||
// only default
|
||||
$strategy = new HIncludeFragmentRenderer($engine);
|
||||
$this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent());
|
||||
}
|
||||
}
|
Reference in New Issue