bug #12539 [TwigBundle] properly set request attributes in controller test (xabbuh)

This PR was merged into the 2.6 branch.

Discussion
----------

[TwigBundle] properly set request attributes in controller test

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

Commits
-------

b3db574 properly set request attributes in controller test
This commit is contained in:
Fabien Potencier 2014-11-21 16:55:01 +01:00
commit 45613b3ec5
2 changed files with 3 additions and 2 deletions

View File

@ -122,7 +122,7 @@ class ExceptionController
// default to a generic HTML exception
$request->setRequestFormat('html');
return new TemplateReference('TwigBundle', 'Exception', $this->debug ? 'exception_full' : $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 >= 2.0

View File

@ -51,7 +51,8 @@ class ExceptionControllerTest extends TestCase
))
);
$request = Request::create('whatever', 'GET', array('showException' => false));
$request = Request::create('whatever', 'GET');
$request->attributes->set('showException', false);
$exception = FlattenException::create(new \Exception(), 404);
$controller = new ExceptionController($twig, /* "showException" defaults to --> */ true);