Add comprehensive test coverage and update notes
This commit is contained in:
40
tests/Unit/UpdateUserProfileInformationTest.php
Normal file
40
tests/Unit/UpdateUserProfileInformationTest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use App\Actions\Fortify\UpdateUserProfileInformation;
|
||||
use App\Models\User;
|
||||
|
||||
it('updates profile without email verification when email unchanged', function (): void {
|
||||
$user = User::factory()->create([
|
||||
'name' => 'Old',
|
||||
'email' => 'old@example.com',
|
||||
]);
|
||||
|
||||
$action = new UpdateUserProfileInformation();
|
||||
$action->update($user, [
|
||||
'name' => 'New Name',
|
||||
'email' => 'old@example.com',
|
||||
]);
|
||||
|
||||
$user->refresh();
|
||||
expect($user->name)->toBe('New Name');
|
||||
expect($user->name_canonical)->toBe('new name');
|
||||
expect($user->email)->toBe('old@example.com');
|
||||
});
|
||||
|
||||
it('resets verification and sends notification when email changes', function (): void {
|
||||
$user = User::factory()->create([
|
||||
'name' => 'Old',
|
||||
'email' => 'old@example.com',
|
||||
'email_verified_at' => now(),
|
||||
]);
|
||||
|
||||
$action = new UpdateUserProfileInformation();
|
||||
$action->update($user, [
|
||||
'name' => 'New Name',
|
||||
'email' => 'new@example.com',
|
||||
]);
|
||||
|
||||
$user->refresh();
|
||||
expect($user->email)->toBe('new@example.com');
|
||||
expect($user->email_verified_at)->toBeNull();
|
||||
});
|
||||
Reference in New Issue
Block a user