From d47886021a59339cbfa74685984a591aa3bda826 Mon Sep 17 00:00:00 2001 From: mohammad-alavi Date: Sun, 3 Oct 2021 10:01:58 +0330 Subject: [PATCH] add test for RedirectIfAuthenticated middleware --- .../RedirectIfAuthenticatedMiddlewareTest.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/Containers/AppSection/Authentication/Tests/Unit/RedirectIfAuthenticatedMiddlewareTest.php diff --git a/app/Containers/AppSection/Authentication/Tests/Unit/RedirectIfAuthenticatedMiddlewareTest.php b/app/Containers/AppSection/Authentication/Tests/Unit/RedirectIfAuthenticatedMiddlewareTest.php new file mode 100644 index 000000000..0f6dc0cb8 --- /dev/null +++ b/app/Containers/AppSection/Authentication/Tests/Unit/RedirectIfAuthenticatedMiddlewareTest.php @@ -0,0 +1,34 @@ +make(); + $this->actingAs($user, 'web'); + + $request = Request::create(RouteServiceProvider::LOGIN); + + $middleware = new RedirectIfAuthenticated(); + + $response = $middleware->handle($request, function ($req) { + $this->assertInstanceOf(Request::class, $req); + }); + + $this->assertEquals($response->getStatusCode(), 302); + } +}