createQtySplitter example

$context->method('getTaxState')->willReturn(CartPrice::TAX_STATE_GROSS);
        $context->method('getItemRounding')->willReturn(new CashRoundingConfig(2, 0.01, true));

        $this->salesChannelContext = $context;
    }

    /** * @dataProvider splitProvider */
    public function testSplit(int $itemQty, int $splitterQty, int $calcExpects): void
    {
        $splitter = $this->createQtySplitter($calcExpects);

        $lineItem = new LineItem(Uuid::randomHex(), LineItem::PRODUCT_LINE_ITEM_TYPE, Uuid::randomHex()$itemQty);
        $lineItem->setPrice(new CalculatedPrice(10, 99, new CalculatedTaxCollection()new TaxRuleCollection()$itemQty));
        $lineItem->setStackable(true);

        $newLineItem = $splitter->split($lineItem$splitterQty$this->salesChannelContext);

        if ($calcExpects <= 0) {
            static::assertEquals($lineItem$newLineItem);
        } else {
            $expectedPrice = 10 * $splitterQty;

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