fix handling of a default 'template' as a string
This commit is contained in:
parent
6dbd1e102b
commit
9d1004b59e
@ -99,7 +99,11 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
|||||||
private function templateExists($template)
|
private function templateExists($template)
|
||||||
{
|
{
|
||||||
if ($this->templating instanceof EngineInterface) {
|
if ($this->templating instanceof EngineInterface) {
|
||||||
|
try {
|
||||||
return $this->templating->exists($template);
|
return $this->templating->exists($template);
|
||||||
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$loader = $this->templating->getLoader();
|
$loader = $this->templating->getLoader();
|
||||||
|
@ -50,7 +50,7 @@ class HIncludeFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('<hx:include src="/foo"></hx:include>', $strategy->render('/foo', Request::create('/'))->getContent());
|
$this->assertEquals('<hx:include src="/foo"></hx:include>', $strategy->render('/foo', Request::create('/'))->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRenderWhithDefault()
|
public function testRenderWithDefault()
|
||||||
{
|
{
|
||||||
// only default
|
// only default
|
||||||
$strategy = new HIncludeFragmentRenderer();
|
$strategy = new HIncludeFragmentRenderer();
|
||||||
@ -64,4 +64,17 @@ class HIncludeFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
|||||||
$strategy = new HIncludeFragmentRenderer(null, null, 'global_default');
|
$strategy = new HIncludeFragmentRenderer(null, null, 'global_default');
|
||||||
$this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent());
|
$this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRenderWithDefaultText()
|
||||||
|
{
|
||||||
|
$engine = $this->getMock('Symfony\\Component\\Templating\\EngineInterface');
|
||||||
|
$engine->expects($this->once())
|
||||||
|
->method('exists')
|
||||||
|
->with('default')
|
||||||
|
->will($this->throwException(new \InvalidArgumentException()));
|
||||||
|
|
||||||
|
// only default
|
||||||
|
$strategy = new HIncludeFragmentRenderer($engine);
|
||||||
|
$this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent());
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user