Fixed templateExists on parse error of the template name
This commit is contained in:
parent
b1f60216a4
commit
53347c42fd
@ -135,7 +135,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
|||||||
if ($this->templating instanceof EngineInterface) {
|
if ($this->templating instanceof EngineInterface) {
|
||||||
try {
|
try {
|
||||||
return $this->templating->exists($template);
|
return $this->templating->exists($template);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,4 +86,17 @@ class HIncludeFragmentRendererTest extends TestCase
|
|||||||
$strategy = new HIncludeFragmentRenderer($engine);
|
$strategy = new HIncludeFragmentRenderer($engine);
|
||||||
$this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent());
|
$this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRenderWithEngineAndDefaultText()
|
||||||
|
{
|
||||||
|
$engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock();
|
||||||
|
$engine->expects($this->once())
|
||||||
|
->method('exists')
|
||||||
|
->with('loading...')
|
||||||
|
->will($this->throwException(new \RuntimeException()));
|
||||||
|
|
||||||
|
// only default
|
||||||
|
$strategy = new HIncludeFragmentRenderer($engine);
|
||||||
|
$this->assertEquals('<hx:include src="/foo">loading...</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'loading...'))->getContent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user