Create tests for app/Listeners/LogLogout
This commit is contained in:
parent
dc552407c4
commit
0f1ed33216
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Actions\Fortify\CreateNewUser;
|
||||||
|
use App\Models\AuditLogEntry;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
$creator = app(CreateNewUser::class);
|
||||||
|
$this->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]);
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue