MaintenanceModeResolver example


class MaintenanceModeResolverTest extends TestCase
{
    public function testIsClientAllowedTriggersEventAndReturnsFalseForDisallowedClient(): void
    {
        $eventDispatcher = $this->createMock(EventDispatcherInterface::class);

        $eventDispatcher->expects(static::once())
            ->method('dispatch')
            ->with(static::isInstanceOf(MaintenanceModeRequestEvent::class));

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

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

        $eventDispatcher->expects(static::once())
            ->method('dispatch')
            ->with(static::isInstanceOf(MaintenanceModeRequestEvent::class));

        


        static::assertSame($expected, CacheResponseSubscriber::getSubscribedEvents());
    }

    public function testNoHeadersAreSetIfCacheIsDisabled(): void
    {
        $subscriber = new CacheResponseSubscriber(
            $this->createMock(CartService::class),
            100,
            false,
            new MaintenanceModeResolver(new RequestStack()new CoreMaintenanceModeResolver(new EventDispatcher())),
            false,
            null,
            null
        );

        $customer = new CustomerEntity();
        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $salesChannelContext->method('getCustomer')->willReturn($customer);

        $request = new Request();
        $request->attributes->set(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_CONTEXT_OBJECT, $salesChannelContext);

        
use Symfony\Component\HttpFoundation\RequestStack;

/** * @internal * * @covers \Shopware\Storefront\Framework\Routing\MaintenanceModeResolver */
class MaintenanceModeResolverTest extends TestCase
{
    public function testShouldInstantiate(): void
    {
        static::assertInstanceOf(MaintenanceModeResolver::classnew MaintenanceModeResolver($this->getRequestStack()new CoreMaintenanceModeResolver(new EventDispatcher())));
    }

    /** * Tests whether the resolver redirects requests to the maintenance page correctly. * * @dataProvider maintenanceModeInactiveProvider * @dataProvider maintenanceModeActiveProvider * @dataProvider xmlHttpRequestProvider * @dataProvider maintenancePageRequestProvider * @dataProvider errorControllerRequestProvider */
    
Home | Imprint | This part of the site doesn't use cookies.