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) {
|
||||
try {
|
||||
return $this->templating->exists($template);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -86,4 +86,17 @@ class HIncludeFragmentRendererTest extends TestCase
|
||||
$strategy = new HIncludeFragmentRenderer($engine);
|
||||
$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