mirror of
https://github.com/usetrmnl/larapaper.git
synced 2026-08-13 14:28:54 -07:00
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>
31 lines
820 B
PHP
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'));
|
|
});
|