ProductCloseoutFilterFactory example

/** * @internal * * @covers \Shopware\Core\Content\Product\SalesChannel\ProductCloseoutFilterFactory */
class ProductCloseoutFilterFactoryTest extends TestCase
{
    public function testCreatesProductCloseoutFilter(): void
    {
        $context = $this->createMock(SalesChannelContext::class);
        $filter = (new ProductCloseoutFilterFactory())->create($context);

        static::assertEquals(new ProductCloseoutFilter()$filter);
    }

    public function testGetDecoratedThrowsDecorationPatternException(): void
    {
        static::expectException(DecorationPatternException::class);
        (new ProductCloseoutFilterFactory())->getDecorated();
    }
}
private EventDispatcher $eventDispatcher;

    private AbstractProductCloseoutFilterFactory $productCloseoutFilterFactory;

    protected function setUp(): void
    {
        $this->productListRouteMock = $this->createMock(ProductListRoute::class);
        $this->systemConfigServiceMock = $this->createMock(SystemConfigService::class);
        $this->salesChannelContextMock = $this->createMock(SalesChannelContext::class);
        $this->eventDispatcher = new EventDispatcher();
        $this->productCloseoutFilterFactory = new ProductCloseoutFilterFactory();
    }

    public function testItThrowsExceptionWithInvalidProductIds(): void
    {
        if (Feature::isActive('v6.6.0.0')) {
            static::expectException(RoutingException::class);
        } else {
            static::expectException(MissingRequestParameterException::class);
        }

        $request = new Request();

        
protected function setUp(): void
    {
        parent::setUp();
        $this->context = $this->createMock(SalesChannelContext::class);
        $this->idsCollection = new IdsCollection();
        $this->productRepository = $this->createMock(SalesChannelRepository::class);
        $this->systemConfig = $this->createMock(SystemConfigService::class);
        $configuratorLoader = $this->createMock(ProductConfiguratorLoader::class);
        $breadcrumbBuilder = $this->createMock(CategoryBreadcrumbBuilder::class);
        $cmsPageLoader = $this->createMock(SalesChannelCmsPageLoader::class);
        $this->productCloseoutFilterFactory = new ProductCloseoutFilterFactory();

        $this->route = new ProductDetailRoute(
            $this->productRepository,
            $this->systemConfig,
            $configuratorLoader,
            $breadcrumbBuilder,
            $cmsPageLoader,
            new SalesChannelProductDefinition(),
            $this->productCloseoutFilterFactory
        );
    }

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