insert([ 'ip_address' => '10.0.0.9', 'attempts' => 1, ]); $service = app(IpBanCommandService::class); $ban = $service->banNow(null, '10.0.0.9', 2); $this->assertNotNull($ban); $this->assertDatabaseHas('ip_attempts', [ 'ip_address' => '10.0.0.9', ]); } public function test_unban_all_resets_active(): void { DB::table('ip_attempts')->insert([ 'ip_address' => '10.0.0.10', 'attempts' => 5, 'blocked_until' => now('UTC')->addHours(3), ]); $service = app(IpBanCommandService::class); $count = $service->unbanAll(); $this->assertSame(1, $count); $this->assertDatabaseHas('ip_attempts', [ 'ip_address' => '10.0.0.10', 'blocked_until' => null, 'attempts' => 0, ]); } }