CategoryRouteResponse example

$salesChannel,
            new CurrencyEntity(),
            new CustomerGroupEntity(),
            new TaxCollection(),
            new PaymentMethodEntity(),
            new ShippingMethodEntity(),
            new ShippingLocation(new CountryEntity(), null, null),
            new CustomerEntity(),
            new CashRoundingConfig(1, 1.1, true),
            new CashRoundingConfig(1, 1.1, true)
        );
        $this->response = new CategoryRouteResponse(
            new CategoryEntity()
        );

        $this->cachedRoute = new CachedCategoryRoute(
            $this->decorated,
            $this->cache,
            $this->createMock(EntityCacheKeyGenerator::class),
            $this->createMock(AbstractCacheTracer::class),
            $this->eventDispatcher,
            []
        );
    }
$this->expectException(MissingRequestParameterException::class);
        }
        $this->expectExceptionMessage('Parameter "navigationId" is missing.');

        $this->controller->category(null, new Request()$this->createMock(SalesChannelContext::class));
    }

    public function testCategoryReturn(): void
    {
        $categoryEntity = new CategoryEntity();
        $categoryEntity->setCmsPage(new CmsPageEntity());
        $categoryRouteResponse = new CategoryRouteResponse($categoryEntity);
        $this->categoryRouteMock->method('load')->willReturn($categoryRouteResponse);

        $ids = new IdsCollection();

        $this->controller->category($ids->get('category')new Request()$this->createMock(SalesChannelContext::class));

        static::assertEquals($categoryRouteResponse->getCategory()->getCmsPage()$this->controller->renderStorefrontParameters['cmsPage']);
    }

    public function testCategoryPageNotFound(): void
    {
        
$pageId = $category->getCmsPageId();
        $slotConfig = $category->getTranslation('slotConfig');

        $salesChannel = $context->getSalesChannel();
        if ($category->getId() === $salesChannel->getNavigationCategoryId() && $salesChannel->getHomeCmsPageId()) {
            $pageId = $salesChannel->getHomeCmsPageId();
            $slotConfig = $salesChannel->getTranslation('homeSlotConfig');
        }

        if (!$pageId) {
            return new CategoryRouteResponse($category);
        }

        $resolverContext = new EntityResolverContext($context$request$this->categoryDefinition, $category);

        $pages = $this->cmsPageLoader->load(
            $request,
            $this->createCriteria($pageId$request),
            $context,
            $slotConfig,
            $resolverContext
        );

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