26 lines
930 B
PHP
26 lines
930 B
PHP
<?php
|
|
|
|
use App\Actions\Fortify\ResetUserPassword;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
$this->user = User::factory()->create();
|
|
});
|
|
|
|
it('resets a user password', function () {
|
|
$changer = app(ResetUserPassword::class);
|
|
$changer->reset($this->user, ['password' => 'password123', 'password_confirmation' => 'password123']);
|
|
$this->user->refresh();
|
|
expect(\Illuminate\Support\Facades\Hash::check('password123', $this->user->password))->toBeTrue();
|
|
});
|
|
|
|
it('logs password change', function () {
|
|
$changer = app(ResetUserPassword::class);
|
|
$changer->reset($this->user, ['password' => 'password123', 'password_confirmation' => 'password123']);
|
|
$logEntry = \App\Models\AuditLogEntry::first();
|
|
expect($logEntry->message)->toEqual('Changed password for '.$this->user->email.' ('.$this->user->full_name().')');
|
|
});
|