Skip to content

Commit

Permalink
Merge branch '4.0' into 4.1
Browse files Browse the repository at this point in the history
* 4.0:
  updated VERSION for 2.8.43
  update CONTRIBUTORS for 2.8.43
  updated CHANGELOG for 2.8.43
  backported translations
  Fixed templateExists on parse error of the template name
  • Loading branch information
nicolas-grekas committed Jul 23, 2018
2 parents f6b9fda + 7da5d16 commit 4c435a0
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 @@ -126,7 +126,7 @@ private function templateExists(string $template): bool
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 4c435a0

Please sign in to comment.