Skip to content

Commit

Permalink
bug #28005 [HttpKernel] Fixed templateExists on parse error of the te…
Browse files Browse the repository at this point in the history
…mplate name (yceruto)

This PR was merged into the 2.8 branch.

Discussion
----------

[HttpKernel] Fixed templateExists on parse error of the template name

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #28001
| License       | MIT
| Doc PR        | -

https://github.com/symfony/symfony/blob/9bfa971bc5662a6f90408b58a7b2453d7dae4f83/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php#L49-L51

Commits
-------

53347c4 Fixed templateExists on parse error of the template name
  • Loading branch information
fabpot committed Jul 23, 2018
2 parents 099db04 + 218dcae commit 1c236ff
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 1c236ff

Please sign in to comment.