当我尝试测试一个调用showAction
ExceptionController
vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php
方法的类时,它会标记为" 冒险& #34;测试,说:
测试代码或测试代码没有(仅)关闭自己的输出缓冲区
示例代码:
$request = Request::create('whatever', 'GET');
$request->attributes->set('showException', false);
$exception = FlattenException::create(new \Exception(), 404);
$controller = new ExceptionController($twig, true);
$response = $controller->showAction($request, $exception, null);
// some assertions....
答案 0 :(得分:0)
为了解决问题,请求的标头X-Php-Ob-Level
应设置为1
:
$request->headers->set('X-Php-Ob-Level', 1);
示例代码:
$request = Request::create('whatever', 'GET');
$request->headers->set('X-Php-Ob-Level', 1);
$request->attributes->set('showException', false);
$exception = FlattenException::create(new \Exception(), 404);
$controller = new ExceptionController($twig, true);
$response = $controller->showAction($request, $exception, null);
// some assertions....