[TwigBundle] add back exception check
This commit is contained in:
parent
9fc9cc4123
commit
46c38df0fd
@ -125,7 +125,7 @@ class ExceptionController
|
|||||||
// default to a generic HTML exception
|
// default to a generic HTML exception
|
||||||
$request->setRequestFormat('html');
|
$request->setRequestFormat('html');
|
||||||
|
|
||||||
return new TemplateReference('TwigBundle', 'Exception', $name, 'html', 'twig');
|
return new TemplateReference('TwigBundle', 'Exception', $showException ? 'exception_full' : $name, 'html', 'twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
// to be removed when the minimum required version of Twig is >= 3.0
|
// to be removed when the minimum required version of Twig is >= 3.0
|
||||||
|
@ -48,6 +48,20 @@ class ExceptionControllerTest extends TestCase
|
|||||||
$this->assertEquals('html', $request->getRequestFormat());
|
$this->assertEquals('html', $request->getRequestFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFallbackToHtmlWithFullExceptionIfNoTemplateForRequestedFormatAndExceptionsShouldBeShown()
|
||||||
|
{
|
||||||
|
$twig = $this->createTwigEnv(array('TwigBundle:Exception:exception_full.html.twig' => '<html></html>'));
|
||||||
|
|
||||||
|
$request = $this->createRequest('txt');
|
||||||
|
$request->attributes->set('showException', true);
|
||||||
|
$exception = FlattenException::create(new \Exception());
|
||||||
|
$controller = new ExceptionController($twig, false);
|
||||||
|
|
||||||
|
$controller->showAction($request, $exception);
|
||||||
|
|
||||||
|
$this->assertEquals('html', $request->getRequestFormat());
|
||||||
|
}
|
||||||
|
|
||||||
public function testResponseHasRequestedMimeType()
|
public function testResponseHasRequestedMimeType()
|
||||||
{
|
{
|
||||||
$twig = $this->createTwigEnv(array('TwigBundle:Exception:error.json.twig' => '{}'));
|
$twig = $this->createTwigEnv(array('TwigBundle:Exception:error.json.twig' => '{}'));
|
||||||
|
Reference in New Issue
Block a user