You could dd($e) and see what is being passed in as an exception under PHPUnit. You could also check for the existence of $e->getStatusCode() using something like this:
if (method_exists('getStatisCode', $e) {
//throw whoops error here
}
Summer Sale! All accounts are 50% off this week.
I recently updated my App\Exceptions\Handler::render() to use filp/whoops. It works perfectly on browser. Problem is when running phpunit and somethings goes wrong, I get undefined method ErrorException::getStatusCode() instead of the actual error.
I know the error emanates from this call, thing is every tutorial to use whoops says to do it this way.
// Inside Handler::render()
return new Response(
$whoops->handleException($e), // pretty page handler
$e->getStatusCode(),
$e->getHeaders()
);
How can I solve it?
Actually I just went for the default way, so I read into the parent's render method and just did as they did:
$fe = FlattenException::create($e);
return new Response(
$whoops->handleException($e),
$fe->getStatusCode(),
$fe->getHeaders()
);
Please or to participate in this conversation.