Level 102
Dec 2, 2021
2
Level 2
Error When Running Unit Test Of Middleware
Hello,
I wrote a unit test and to test a middleware, when I run the test, this is the error showing in the console.
• Tests\Unit\MAMiddlewareTest > token failed status not authorized
Illuminate\Contracts\Container\BindingResolutionException
Target [Illuminate\Contracts\Routing\ResponseFactory] is not instantiable.
Here is the test that I wrote.
public function token_failed_status_not_authorized() {
$token = "ma-page-access";
$request = Request::create('/test', 'GET');
$request->query->add(['token' => $token]);
$middleware = new MyAccountAccessCheckMiddleware;
$response = $middleware->handle($request, function () {});
$this->assertEquals($response->getStatusCode(), 200);
}
Please or to participate in this conversation.