2024-08-01 13:53:10 -05:00
|
|
|
<?php
|
|
|
|
|
|
2025-01-28 17:33:54 -06:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2024-09-06 19:39:04 -05:00
|
|
|
namespace Tests;
|
2024-08-01 13:53:10 -05:00
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
|
use Livewire\Livewire;
|
|
|
|
|
|
|
|
|
|
class ProfileInformationTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
use RefreshDatabase;
|
|
|
|
|
|
|
|
|
|
public function test_current_profile_information_is_available(): void
|
|
|
|
|
{
|
|
|
|
|
$this->actingAs($user = User::factory()->create());
|
|
|
|
|
|
2025-09-26 17:41:28 -05:00
|
|
|
$component = Livewire::test('update-profile-information-form');
|
2024-08-01 13:53:10 -05:00
|
|
|
|
|
|
|
|
$this->assertEquals($user->name, $component->state['name']);
|
|
|
|
|
$this->assertEquals($user->email, $component->state['email']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function test_profile_information_can_be_updated(): void
|
|
|
|
|
{
|
|
|
|
|
$this->actingAs($user = User::factory()->create());
|
|
|
|
|
|
2025-09-26 17:41:28 -05:00
|
|
|
Livewire::test('update-profile-information-form')
|
2024-08-01 13:53:10 -05:00
|
|
|
->set('state', ['name' => 'Test Name', 'email' => 'test@example.com'])
|
|
|
|
|
->call('updateProfileInformation');
|
|
|
|
|
|
|
|
|
|
$this->assertEquals('Test Name', $user->fresh()->name);
|
|
|
|
|
$this->assertEquals('test@example.com', $user->fresh()->email);
|
|
|
|
|
}
|
|
|
|
|
}
|