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