我正在为在应用程序中注册新用户的 Controller 编写功能测试。
我正在编写的测试由于 500 HTTP 错误而失败。
我正在使用
$response = $client->getResponse();
print_r($response->getContent());exit;
打印 HTML 以查看发生了什么,但 HTML 在我的控制台 (PHPStorm) 中不完整,因此我不知道到底发生了什么,也无法找到错误来解决它。
关于如何理解正在发生的事情以及导致错误的原因有什么想法吗?
最佳答案
也许这些可以帮助:app/logs
文件夹中有一个test.log
文件,您可以将其删除,运行测试,当错误发生时打开新生成的文件,读取发生了什么,就是这样。
或者将 DebugBundle
添加到 AppKernel.php
文件中的 registerBundles
方法,并使用其 dump()
方法,像这样:
// AppKernel.php
if (in_array($this->getEnvironment(), ['dev', 'test'])) {
...
$bundles[] = new \Symfony\Bundle\DebugBundle\DebugBundle();
}
*****
// usage:
public function testSomeAction()
{
.....
$response = $client->getResponse();
dump($response);
die;
}
关于php - Symfony 功能测试 : how to understand why the test fails (with a 500 Error),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30816901/