8000 Fixed templateExists on parse error of the template name · symfony/symfony@53347c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 53347c4

Browse files
committed
Fixed templateExists on parse error of the template name
1 parent b1f6021 commit 53347c4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ private function templateExists($template)
135135
if ($this->templating instanceof EngineInterface) {
136136
try {
137137
return $this->templating->exists($template);
138-
} catch (\InvalidArgumentException $e) {
138+
} catch (\Exception $e) {
139139
return false;
140140
}
141141
}

src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,17 @@ public function testRenderWithDefaultText()
8686
$strategy = new HIncludeFragmentRenderer($engine);
8787
$this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent());
8888
}
89+
90+
public function testRenderWithEngineAndDefaultText()
91+
{
92+
$engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock();
93+
$engine->expects($this->once())
94+
->method('exists')
95+
->with('loading...')
96+
->will($this->throwException(new \RuntimeException()));
97+
98+
// only default
99+
$strategy = new HIncludeFragmentRenderer($engine);
100+
$this->assertEquals('<hx:include src="/foo">loading...</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'loading...'))->getContent());
101+
}
89102
}

0 commit comments

Comments
 (0)
0