Skip to content

Commit

Permalink
Fixed templateExists on parse error of the template name
Browse files Browse the repository at this point in the history
  • Loading branch information
yceruto committed Jul 19, 2018
1 parent a5ae20f commit 218dcae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Fragment/HIncludeFragmentRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private function templateExists($template)
if ($this->templating instanceof EngineInterface) {
try {
return $this->templating->exists($template);
} catch (\InvalidArgumentException $e) {
} catch (\Exception $e) {
return false;
}
}
Expand Down
13 changes: 13 additions & 0 deletions Tests/Fragment/HIncludeFragmentRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,17 @@ public function testRenderWithDefaultText()
$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());
}
}

0 comments on commit 218dcae

Please sign in to comment.