PasswordConfirmationTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Tests\Feature\Auth;
  3. use App\Models\User;
  4. use Illuminate\Foundation\Testing\RefreshDatabase;
  5. use Livewire\Volt\Volt;
  6. use Tests\TestCase;
  7. class PasswordConfirmationTest extends TestCase
  8. {
  9. use RefreshDatabase;
  10. public function test_confirm_password_screen_can_be_rendered(): void
  11. {
  12. $user = User::factory()->create();
  13. $response = $this->actingAs($user)->get('/confirm-password');
  14. $response
  15. ->assertSeeVolt('pages.auth.confirm-password')
  16. ->assertStatus(200);
  17. }
  18. public function test_password_can_be_confirmed(): void
  19. {
  20. $user = User::factory()->create();
  21. $this->actingAs($user);
  22. $component = Volt::test('pages.auth.confirm-password')
  23. ->set('password', 'password');
  24. $component->call('confirmPassword');
  25. $component
  26. ->assertRedirect('/dashboard')
  27. ->assertHasNoErrors();
  28. }
  29. public function test_password_is_not_confirmed_with_invalid_password(): void
  30. {
  31. $user = User::factory()->create();
  32. $this->actingAs($user);
  33. $component = Volt::test('pages.auth.confirm-password')
  34. ->set('password', 'wrong-password');
  35. $component->call('confirmPassword');
  36. $component
  37. ->assertNoRedirect()
  38. ->assertHasErrors('password');
  39. }
  40. }