Add extensive controller and model tests
All checks were successful
CI/CD Pipeline / test (push) Successful in 10s
CI/CD Pipeline / deploy (push) Successful in 25s

This commit is contained in:
2026-02-07 22:14:42 +01:00
parent 9c60a8944e
commit 160430e128
39 changed files with 3941 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
<?php
use App\Providers\FortifyServiceProvider;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use Illuminate\Session\Store;
use Illuminate\Session\ArraySessionHandler;
use Laravel\Fortify\Fortify;
it('registers rate limiters for login and two-factor', function (): void {
(new FortifyServiceProvider(app()))->boot();
$loginLimiter = RateLimiter::limiter('login');
$twoFactorLimiter = RateLimiter::limiter('two-factor');
$request = Request::create('/login', 'POST', [
Fortify::username() => 'Test@Example.com',
]);
$request->server->set('REMOTE_ADDR', '127.0.0.1');
$request->setLaravelSession(new Store('test', new ArraySessionHandler(60)));
$request->session()->put('login.id', 'login-id');
$loginLimit = $loginLimiter($request);
expect($loginLimit)->toBeInstanceOf(Limit::class);
expect($loginLimit->maxAttempts)->toBe(5);
expect($loginLimit->key)->toBe(Str::transliterate('test@example.com|127.0.0.1'));
$twoFactorLimit = $twoFactorLimiter($request);
expect($twoFactorLimit)->toBeInstanceOf(Limit::class);
expect($twoFactorLimit->maxAttempts)->toBe(5);
});