04 10 2023 snapshot

This commit is contained in:
Anatoliy Poloz
2023-10-04 17:57:09 +03:00
parent 1e546fa48e
commit 09a00744a0
441 changed files with 41582 additions and 254079 deletions

View File

@@ -4,6 +4,7 @@ namespace Tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Fortify\Features;
use Laravel\Jetstream\Http\Livewire\TwoFactorAuthenticationForm;
use Livewire\Livewire;
use Tests\TestCase;
@@ -12,14 +13,20 @@ class TwoFactorAuthenticationSettingsTest extends TestCase
{
use RefreshDatabase;
public function test_two_factor_authentication_can_be_enabled()
public function test_two_factor_authentication_can_be_enabled(): void
{
if (! Features::canManageTwoFactorAuthentication()) {
$this->markTestSkipped('Two factor authentication is not enabled.');
return;
}
$this->actingAs($user = User::factory()->create());
$this->withSession(['auth.password_confirmed_at' => time()]);
Livewire::test(TwoFactorAuthenticationForm::class)
->call('enableTwoFactorAuthentication');
->call('enableTwoFactorAuthentication');
$user = $user->fresh();
@@ -27,15 +34,21 @@ class TwoFactorAuthenticationSettingsTest extends TestCase
$this->assertCount(8, $user->recoveryCodes());
}
public function test_recovery_codes_can_be_regenerated()
public function test_recovery_codes_can_be_regenerated(): void
{
if (! Features::canManageTwoFactorAuthentication()) {
$this->markTestSkipped('Two factor authentication is not enabled.');
return;
}
$this->actingAs($user = User::factory()->create());
$this->withSession(['auth.password_confirmed_at' => time()]);
$component = Livewire::test(TwoFactorAuthenticationForm::class)
->call('enableTwoFactorAuthentication')
->call('regenerateRecoveryCodes');
->call('enableTwoFactorAuthentication')
->call('regenerateRecoveryCodes');
$user = $user->fresh();
@@ -45,14 +58,20 @@ class TwoFactorAuthenticationSettingsTest extends TestCase
$this->assertCount(8, array_diff($user->recoveryCodes(), $user->fresh()->recoveryCodes()));
}
public function test_two_factor_authentication_can_be_disabled()
public function test_two_factor_authentication_can_be_disabled(): void
{
if (! Features::canManageTwoFactorAuthentication()) {
$this->markTestSkipped('Two factor authentication is not enabled.');
return;
}
$this->actingAs($user = User::factory()->create());
$this->withSession(['auth.password_confirmed_at' => time()]);
$component = Livewire::test(TwoFactorAuthenticationForm::class)
->call('enableTwoFactorAuthentication');
->call('enableTwoFactorAuthentication');
$this->assertNotNull($user->fresh()->two_factor_secret);