Files
larapaper/tests/Feature/Auth/TwoFactorChallengeTest.php
Benjamin NussbaumandCursor f2ff4ad111 starter-kit-upgrade: Browser tests & Fortify skip guards
Upstream: laravel/livewire-starter-kit@0ca77fa
Adds skipUnlessFortifyHas on TestCase and Fortify-aware skips/assertions in auth tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-26 18:07:58 +02:00

31 lines
820 B
PHP

<?php
use App\Models\User;
use Laravel\Fortify\Features;
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
beforeEach(function (): void {
$this->skipUnlessFortifyHas(Features::twoFactorAuthentication());
});
test('two_factor_challenge_redirects_to_login_when_not_authenticated', function (): void {
$response = $this->get(route('two-factor.login'));
$response->assertRedirect(route('login'));
});
test('two_factor_challenge_can_be_rendered', function (): void {
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'));
});