ProductLineItemValidator example

->setMaxPurchase(1)
                        ->setPurchaseSteps(1)
                )
        );

        $cart->setBehavior(new CartBehavior([
            ProductCartProcessor::SKIP_PRODUCT_STOCK_VALIDATION => true,
        ]));

        static::assertCount(0, $cart->getErrors());

        $validator = new ProductLineItemValidator();
        $validator->validate($cart$cart->getErrors()$salesChannelContext);

        static::assertCount(0, $cart->getErrors());
    }

    public function testValidateOnDuplicateProductsAtMaxPurchase(): void
    {
        $cart = new Cart(Uuid::randomHex());
        $builder = new ProductLineItemFactory(new PriceDefinitionFactory());
        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $cart->add(
            
Home | Imprint | This part of the site doesn't use cookies.