How to test if render()
an exception into an HTTP response working correctly. I want to test without calling $this->get()
This is a method in Laravel:
public function render($request, Exception $e)
{
$response['exception'] = get_class($e);
$response['message'] = $e->getMessage();
if ($e instanceof LockException) {
return $this->errorResponse('lock', $response, 'Lock error has occurred', $e->getCode());
}
return parent::render($request, $e);
}
I need to test if LockException
has turn into an HTTP response.
Something like this. In your test, instantiate the controller into a variable, create a blank request and pass in your LockException:
$response = $controller->render($request, $exception);
$this->assertEquals('string of HTML you expect', $response);