Init
This commit is contained in:
23 files changed
+1216
No files matched your search
@@ -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 * * *');
|
||||
});
|
||||
Reference in new issue
Block a user