mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-16 16:37:47 +00:00
34 lines
998 B
PHP
34 lines
998 B
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use Laravel\Fortify\Features;
|
|
|
|
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
|
|
|
|
test('two_factor_challenge_redirects_to_login_when_not_authenticated', function (): void {
|
|
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 (): void {
|
|
if (! Features::canManageTwoFactorAuthentication()) {
|
|
$this->markTestSkipped('Two-factor authentication is not enabled.');
|
|
}
|
|
|
|
Features::twoFactorAuthentication([
|
|
'confirm' => true,
|
|
'confirmPassword' => true,
|
|
]);
|
|
|
|
$user = User::factory()->withTwoFactor()->create();
|
|
|
|
$this->post(route('login.store'), [
|
|
'email' => $user->email,
|
|
'password' => 'password',
|
|
])->assertRedirect(route('two-factor.login'));
|
|
});
|