CartHasDeliveryFreeItemRule example


class CartHasDeliveryFreeItemRuleTest extends TestCase
{
    /** * @dataProvider inputProvider */
    public function testMatchInLineItemScope(?bool $lineItemWithFreeDelivery): void
    {
        $scope = new LineItemScope($this->getLineItem($lineItemWithFreeDelivery)$this->createMock(SalesChannelContext::class));

        $rule = new CartHasDeliveryFreeItemRule(true);
        static::assertSame($lineItemWithFreeDelivery ?? false, $rule->match($scope));
        $rule = new CartHasDeliveryFreeItemRule(false);
        static::assertSame(!$lineItemWithFreeDelivery$rule->match($scope));
    }

    /** * @dataProvider inputProvider */
    public function testMatchInCartScope(?bool $lineItemWithFreeDelivery): void
    {
        $scope = new CartRuleScope(new Cart(Uuid::randomHex())$this->createMock(SalesChannelContext::class));
        


    public function testIfShippingFreeLineItemsAreCaught(): void
    {
        $lineItemCollection = new LineItemCollection([
            $this->createLineItemWithDeliveryInfo(false),
            $this->createLineItemWithDeliveryInfo(true),
        ]);

        $cart = $this->createCart($lineItemCollection);

        $match = (new CartHasDeliveryFreeItemRule())
            ->match(new CartRuleScope($cart$this->createMock(SalesChannelContext::class)));

        static::assertTrue($match);
    }

    public function testIfShippingFreeNestedLineItemsAreCaught(): void
    {
        $childLineItemCollection = new LineItemCollection([
            $this->createLineItemWithDeliveryInfo(false),
            $this->createLineItemWithDeliveryInfo(true),
        ]);

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