herbarium/tests/Feature/Auth/TwoFactorChallengeTest.php
Alyx Batte 5280d46d07
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
initial commit
2025-11-18 19:31:28 -05:00

32 lines
907 B
PHP

<?php
use App\Models\User;
use Laravel\Fortify\Features;
test('two factor challenge redirects to login when not authenticated', function () {
if (! Features::canManageTwoFactorAuthentication()) {
$this->markTestSkipped('Two-factor authentication is not enabled.');
}
$response = $this->get(route('two-factor.login'));
$response->assertRedirect(route('login'));
});
test('two factor challenge can be rendered', function () {
if (! Features::canManageTwoFactorAuthentication()) {
$this->markTestSkipped('Two-factor authentication is not enabled.');
}
Features::twoFactorAuthentication([
'confirm' => true,
'confirmPassword' => true,
]);
$user = User::factory()->create();
$this->post(route('login.store'), [
'email' => $user->email,
'password' => 'password',
])->assertRedirect(route('two-factor.login'));
});