forge/tests/Feature/User/ProfileInformationTest.php

29 lines
881 B
PHP
Raw Normal View History

2024-07-18 00:11:32 -04:00
<?php
2025-01-30 00:23:55 -05:00
declare(strict_types=1);
2024-07-18 00:11:32 -04:00
use App\Models\User;
use Laravel\Jetstream\Http\Livewire\UpdateProfileInformationForm;
use Livewire\Livewire;
2025-01-30 00:23:55 -05:00
test('current profile information is available', function (): void {
2024-07-18 00:11:32 -04:00
$this->actingAs($user = User::factory()->create());
2025-01-30 00:23:55 -05:00
$testable = Livewire::test(UpdateProfileInformationForm::class);
2024-07-18 00:11:32 -04:00
2025-01-30 00:23:55 -05:00
expect($testable->state['name'])->toEqual($user->name);
expect($testable->state['email'])->toEqual($user->email);
2024-07-18 00:11:32 -04:00
});
2025-01-30 00:23:55 -05:00
test('profile information can be updated', function (): void {
2024-07-18 00:11:32 -04:00
$this->actingAs($user = User::factory()->create());
Livewire::test(UpdateProfileInformationForm::class)
->set('state', ['name' => 'Test Name', 'email' => 'test@example.com'])
->call('updateProfileInformation');
expect($user->fresh())
->name->toEqual('Test Name')
->email->toEqual('test@example.com');
});