DeliveryCalculator example

$data = new CartDataCollection();

        $cart = new Cart('test');
        $cartBehavior = new CartBehavior([
            DeliveryProcessor::SKIP_DELIVERY_PRICE_RECALCULATION => true,
        ]);
        $cart->setBehavior($cartBehavior);

        $quantityPriceCalculatorMock = $this->createMock(QuantityPriceCalculator::class);
        $quantityPriceCalculatorMock->expects(static::once())->method('calculate')->willReturn($costs);

        $deliveryCalculator = new DeliveryCalculator(
            $quantityPriceCalculatorMock,
            $this->createMock(PercentageTaxRuleBuilder::class),
        );

        $deliveryCalculator->calculate($data$cartnew DeliveryCollection([$delivery])$context);
        static::assertNotNull($newCosts);
        static::assertSame($costs->getUnitPrice()$newCosts->getUnitPrice());
        static::assertSame($costs->getTotalPrice()$newCosts->getTotalPrice());
    }
}
Home | Imprint | This part of the site doesn't use cookies.