From 0f1ed33216e5c39bd3590013a17d9ba3ab652e2d Mon Sep 17 00:00:00 2001 From: Matt Young Date: Thu, 3 Jul 2025 00:31:20 -0500 Subject: [PATCH] Create tests for app/Listeners/LogLogout --- tests/Feature/app/Listeners/LogLogoutTest.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/Feature/app/Listeners/LogLogoutTest.php diff --git a/tests/Feature/app/Listeners/LogLogoutTest.php b/tests/Feature/app/Listeners/LogLogoutTest.php new file mode 100644 index 0000000..63f9911 --- /dev/null +++ b/tests/Feature/app/Listeners/LogLogoutTest.php @@ -0,0 +1,36 @@ +user = $creator->create([ + 'registration_code' => 'secret', + 'first_name' => 'Percy', + 'last_name' => 'Grainger', + 'judging_preference' => 'Sarrousaphone', + 'cell_phone' => '0123456789', + 'email' => 'audition@admin.com', + 'password' => 'password', + 'password_confirmation' => 'password', + ]); + $this->user->email_verified_at = now(); + $this->user->save(); + $this->user->refresh(); +}); + +test('Logouts are logged', function () { + $this->actingAs($this->user); + $response = $this->post('/logout', [], [ + 'REMOTE_ADDR' => '123.123.123.123', + ]); + $lastLog = AuditLogEntry::orderBy('id', 'desc')->first(); + expect($lastLog->message)->toEqual('Logged Out') + ->and($lastLog->user)->toEqual($this->user->email) + ->and($lastLog->ip_address)->toEqual('123.123.123.123') + ->and($lastLog->affected['users'])->toEqual([$this->user->id]); +});