Symfony Functional Testing: how to understand why the test fails (with a 500 Error)

674 views Asked by At

I'm writing functional tests for a controller that registers a new user in the app.

The test I'm writing fails because of a 500 HTTP error.

I'm using

$response = $client->getResponse();
print_r($response->getContent());exit;

to print the HTML to see what is happening but the HTML is incomplete in my console (PHPStorm) so i don't know exactly what is happening and cannot find the error to solve it.

Any ideas about how to understand what is happening and what is causing the error?

1

There are 1 answers

0
xurshid29 On BEST ANSWER

May be these can help: there is a test.log file in app/logs folder, you can remove it, run the tests, when the error happens open the newly generated file, read what happend, that's it.

Or you add DebugBundle to registerBundles method in AppKernel.php file, and use its dump() method, like this:

// 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;
}