This commit is contained in:
mathiaspalmqvist committed 2026-11-11 23:19:20 +01:00
commit 3ed6eb9d19
23 files changed
+1216

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
<?php
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Contracts\Http\Kernel;
use Mattitja\BadIpBlocker\Middleware\CheckBadIps;
it('registers the middleware globally without any setup', function () {
expect(app(Kernel::class)->hasMiddleware(CheckBadIps::class))->toBeTrue();
});
it('does not register the middleware twice when the app also adds it', function () {
app(Kernel::class)->pushMiddleware(CheckBadIps::class);
$count = collect(app(Kernel::class)->getGlobalMiddleware())
->filter(fn ($middleware) => $middleware === CheckBadIps::class)
->count();
expect($count)->toBe(1);
});
it('schedules a daily prune', function () {
$event = collect(app(Schedule::class)->events())
->first(fn ($event) => str_contains($event->command ?? '', 'bad-ip-blocker:prune'));
expect($event)->not->toBeNull()
->and($event->expression)->toBe('0 0 * * *');
});