allowClient example

new Request(),
            [],
            true
        );

        static::assertTrue($event->isClientAllowed());

        $event->disallowClient();

        static::assertFalse($event->isClientAllowed());

        $event->allowClient();

        static::assertTrue($event->isClientAllowed());
    }

    public function testGetAllowedIps(): void
    {
        $event = new MaintenanceModeRequestEvent(
            new Request(),
            ['192.168.0.1'],
            true
        );

        


    public function testClientIsDisallowedButEventAllowsIt(): void
    {
        $eventDispatcher = $this->createMock(EventDispatcherInterface::class);

        $eventDispatcher->expects(static::once())
            ->method('dispatch')
            ->with(static::isInstanceOf(MaintenanceModeRequestEvent::class))
            ->willReturnCallback(function DMaintenanceModeRequestEvent $event) {
                static::assertFalse($event->isClientAllowed());
                $event->allowClient();

                return $event;
            });

        $resolver = new MaintenanceModeResolver($eventDispatcher);
        static::assertTrue($resolver->isClientAllowed(new Request(server: ['REMOTE_ADDR' => '192.168.0.4'])[]));
    }
}
Home | Imprint | This part of the site doesn't use cookies.