ProfileInformationTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Tests\Feature;
  3. use App\Models\User;
  4. use Illuminate\Foundation\Testing\RefreshDatabase;
  5. use Laravel\Jetstream\Http\Livewire\UpdateProfileInformationForm;
  6. use Livewire\Livewire;
  7. use Tests\TestCase;
  8. class ProfileInformationTest extends TestCase
  9. {
  10. use RefreshDatabase;
  11. public function test_current_profile_information_is_available()
  12. {
  13. $this->actingAs($user = User::factory()->create());
  14. $component = Livewire::test(UpdateProfileInformationForm::class);
  15. $this->assertEquals($user->name, $component->state['name']);
  16. $this->assertEquals($user->email, $component->state['email']);
  17. }
  18. public function test_profile_information_can_be_updated()
  19. {
  20. $this->actingAs($user = User::factory()->create());
  21. Livewire::test(UpdateProfileInformationForm::class)
  22. ->set('state', ['name' => 'Test Name', 'email' => 'test@example.com'])
  23. ->call('updateProfileInformation');
  24. $this->assertEquals('Test Name', $user->fresh()->name);
  25. $this->assertEquals('test@example.com', $user->fresh()->email);
  26. }
  27. }