Aerendir
Aerendir

Reputation: 6379

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

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?

Upvotes: 2

Views: 707

Answers (1)

xurshid29
xurshid29

Reputation: 4210

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

Upvotes: 2

Related Questions