With my symfony 2 application, i am using phpunit to test if each controller's action response's status code is the expected one.
When not, how can I have phpunit display the error message that comes with the exception, or best, simulate a profiler exception page ?
The reason for this is I have an action returning a 500 code in phpunit but which loads just fine in my browser.
My code :
* @dataProvider urlProvider
* @param $url
public function testPageIsSuccessful($url)
$client = self::createClient(array(), array(
'PHP_AUTH_USER' => 'superadmin',
'PHP_AUTH_PW' => '587010',
You can get the rendered HTML in your test with the following code:
You have to put this just before the failing test and PHPUnit will display the HTML code. It's not convenient but it helped me many times.