56 lines
1.5 KiB
PHP
56 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Auth;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Inertia\Testing\AssertableInertia as Assert;
|
|
use Tests\TestCase;
|
|
|
|
class PasswordConfirmationTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_confirm_password_screen_can_be_rendered(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
|
|
$response = $this->actingAs($user)->get(route('password.confirm'));
|
|
|
|
$response->assertOk();
|
|
|
|
$response->assertInertia(fn (Assert $page) => $page
|
|
->component('auth/ConfirmPassword'),
|
|
);
|
|
}
|
|
|
|
public function test_password_confirmation_requires_authentication(): void
|
|
{
|
|
$response = $this->get(route('password.confirm'));
|
|
|
|
$response->assertRedirect(route('login'));
|
|
}
|
|
|
|
public function test_password_can_be_confirmed(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)
|
|
->post(route('password.confirm'), ['password' => 'password'])
|
|
->assertSessionHasNoErrors();
|
|
|
|
$this->assertNotNull(session('auth.password_confirmed_at'));
|
|
}
|
|
|
|
public function test_password_confirmation_rejects_an_invalid_password(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)
|
|
->post(route('password.confirm'), ['password' => 'incorrect'])
|
|
->assertSessionHasErrors('password');
|
|
|
|
$this->assertNull(session('auth.password_confirmed_at'));
|
|
}
|
|
}
|