disallowClient example


    public function testIsClientAllowed(): void
    {
        $event = new MaintenanceModeRequestEvent(
            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(
            


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

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

                return $event;
            });

        $resolver = new MaintenanceModeResolver($eventDispatcher);
        static::assertFalse($resolver->isClientAllowed(new Request(server: ['REMOTE_ADDR' => '192.168.0.4'])['192.168.0.4']));
    }

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

        
Home | Imprint | This part of the site doesn't use cookies.