From a649d2a6cc0c6bff61ed95193429025816ee4b2a Mon Sep 17 00:00:00 2001 From: Francisco Madeira Date: Wed, 6 Sep 2023 12:30:12 +0100 Subject: [PATCH] Add logout tests. --- .../api/pest-tests/Feature/Auth/AuthenticationTest.php | 9 +++++++++ stubs/api/tests/Feature/Auth/AuthenticationTest.php | 10 ++++++++++ .../pest-tests/Feature/Auth/AuthenticationTest.php | 9 +++++++++ .../default/tests/Feature/Auth/AuthenticationTest.php | 10 ++++++++++ 4 files changed, 38 insertions(+) diff --git a/stubs/api/pest-tests/Feature/Auth/AuthenticationTest.php b/stubs/api/pest-tests/Feature/Auth/AuthenticationTest.php index 2bdcca135..316a4f4b8 100644 --- a/stubs/api/pest-tests/Feature/Auth/AuthenticationTest.php +++ b/stubs/api/pest-tests/Feature/Auth/AuthenticationTest.php @@ -24,3 +24,12 @@ $this->assertGuest(); }); + +test('users can logout', function () { + $user = User::factory()->create(); + + $response = $this->actingAs($user)->post('/logout'); + + $this->assertGuest(); + $response->assertNoContent(); +}); diff --git a/stubs/api/tests/Feature/Auth/AuthenticationTest.php b/stubs/api/tests/Feature/Auth/AuthenticationTest.php index 9042cafa2..223655166 100644 --- a/stubs/api/tests/Feature/Auth/AuthenticationTest.php +++ b/stubs/api/tests/Feature/Auth/AuthenticationTest.php @@ -34,4 +34,14 @@ public function test_users_can_not_authenticate_with_invalid_password(): void $this->assertGuest(); } + + public function test_users_can_logout(): void + { + $user = User::factory()->create(); + + $response = $this->actingAs($user)->post('/logout'); + + $this->assertGuest(); + $response->assertNoContent(); + } } diff --git a/stubs/default/pest-tests/Feature/Auth/AuthenticationTest.php b/stubs/default/pest-tests/Feature/Auth/AuthenticationTest.php index a19f60e3e..45c9c808c 100644 --- a/stubs/default/pest-tests/Feature/Auth/AuthenticationTest.php +++ b/stubs/default/pest-tests/Feature/Auth/AuthenticationTest.php @@ -31,3 +31,12 @@ $this->assertGuest(); }); + +test('users can logout', function () { + $user = User::factory()->create(); + + $response = $this->actingAs($user)->post('/logout'); + + $this->assertGuest(); + $response->assertRedirect('/'); +}); diff --git a/stubs/default/tests/Feature/Auth/AuthenticationTest.php b/stubs/default/tests/Feature/Auth/AuthenticationTest.php index 2d0eeed6a..0303b2908 100644 --- a/stubs/default/tests/Feature/Auth/AuthenticationTest.php +++ b/stubs/default/tests/Feature/Auth/AuthenticationTest.php @@ -42,4 +42,14 @@ public function test_users_can_not_authenticate_with_invalid_password(): void $this->assertGuest(); } + + public function test_users_can_logout(): void + { + $user = User::factory()->create(); + + $response = $this->actingAs($user)->post('/logout'); + + $this->assertGuest(); + $response->assertRedirect('/'); + } }