Benny
Benny

Reputation: 879

Cannot see response get request laravel phpunit

Excuses if this might be a duplicate, but I am not sure how to achieve the following. I am using phpunit to do some tests on routes in laravel and I am not able to receive any debugging information on why the route failed.

This is the code I am trying to test which simply calls some named routes:

foreach($companyNames as $companyName){
    $response = $this->call('GET', Config::get('app.url') . '/provider/' . $companyName);
    $response->assertStatus(200);
  }

The response I get from this when the assertStatus fails is:

1) Tests\Unit\ProviderPageRouteTest::testProviderPageRoutes

Expected status code 200 but received 404.

Failed asserting that false is true.

But what I want to see now is what route exactly failed so I can investigate the reason for the failed route. How can I receive this information from the response or request?

Upvotes: 2

Views: 2291

Answers (1)

user320487
user320487

Reputation:

Before the assertion, dd or log the following:

$response->exception->getStackTrace();

You can access any other exception message for the given class as well.

Upvotes: 2

Related Questions