OrderDeliveryCollection example

$orderLineItemCollection->add($orderLineItem);

        // Order delivery position         $orderDeliveryPositionCollection = new OrderDeliveryPositionCollection();
        $orderDeliveryPosition = new OrderDeliveryPositionEntity();
        $orderDeliveryPosition->setId('order-delivery-position-id-1');
        $orderDeliveryPosition->setOrderLineItem($orderLineItem);
        $orderDeliveryPosition->setPrice(new CalculatedPrice(1, 1, new CalculatedTaxCollection()new TaxRuleCollection()));
        $orderDeliveryPositionCollection->add($orderDeliveryPosition);

        // Order delivery         $orderDeliveryCollection = new OrderDeliveryCollection();
        $orderDelivery = new OrderDeliveryEntity();
        $orderDelivery->setId('order-delivery-id');
        $orderDelivery->setShippingDateEarliest(new \DateTimeImmutable());
        $orderDelivery->setShippingDateLatest(new \DateTimeImmutable());
        $orderDelivery->setShippingMethodId('order-delivery-shipping-method-id');
        $orderDelivery->setShippingOrderAddress($this->getOrderAddress());
        $orderDelivery->setShippingCosts(new CalculatedPrice(1, 1, new CalculatedTaxCollection()new TaxRuleCollection()));
        if ($toManipulate !== 'order-delivery-no-shipping-method') {
            $orderDelivery->setShippingMethod(new ShippingMethodEntity());
        }
        if ($toManipulate !== 'order-delivery-no-position') {
            
static::assertEquals(RuleConstraints::uuids()$constraints['stateIds']);
        static::assertEquals(RuleConstraints::uuidOperators(false)$constraints['operator']);
    }

    /** * @dataProvider getMatchingValues * * @param list<string> $selectedOrderStateIds */
    public function testOrderDeliveryStatusRuleMatching(bool $expected, string $orderStateId, array $selectedOrderStateIds, string $operator): void
    {
        $orderDeliveryCollection = new OrderDeliveryCollection();
        $orderDelivery = new OrderDeliveryEntity();
        $orderDelivery->setId(Uuid::randomHex());
        $orderDelivery->setStateId($orderStateId);
        $orderDeliveryCollection->add($orderDelivery);
        $order = new OrderEntity();
        $order->setDeliveries($orderDeliveryCollection);

        $cart = $this->createMock(Cart::class);
        $context = $this->createMock(SalesChannelContext::class);
        $scope = new FlowRuleScope($order$cart$context);

        
$salesChannelContext = Generator::createSalesChannelContext();
        $salesChannelContext->assign([
            'currency' => (new CurrencyEntity())->assign([
                'id' => $ids->get('currency'),
            ]),
        ]);

        $order = (new OrderEntity())->assign([
            '_uniqueIdentifier' => Uuid::randomHex(),
            'currencyId' => $ids->get('currency'),
            'deliveries' => new OrderDeliveryCollection(),
        ]);
        $orders = new OrderCollection([$order]);

        $accountRouteResponse = new OrderRouteResponse(
            new EntitySearchResult(
                OrderDefinition::ENTITY_NAME,
                1,
                $orders,
                null,
                new Criteria(),
                Context::createDefaultContext()
            )
/** * @dataProvider getRuleTestData * * @param list<string> $trackingCodeData */
    public function testIfMatches(
        OrderTrackingCodeRule $rule,
        array $trackingCodeData,
        bool $expected
    ): void {
        $orderDeliveryCollection = new OrderDeliveryCollection();
        $orderDelivery = new OrderDeliveryEntity();
        $orderDelivery->setId(Uuid::randomHex());
        $orderDelivery->setTrackingCodes($trackingCodeData);
        $orderDeliveryCollection->add($orderDelivery);

        $order = new OrderEntity();
        $order->setDeliveries($orderDeliveryCollection);

        $cart = $this->createMock(Cart::class);
        $context = $this->createMock(SalesChannelContext::class);

        
$this->orderConverter = $this->createMock(OrderConverter::class);
        $this->cartRuleLoader = $this->createMock(CartRuleLoader::class);
        $this->context = Context::createDefaultContext();
    }

    public function testRecalculateOrderWithTaxStatus(): void
    {
        $deliveryEntity = new OrderDeliveryEntity();
        $deliveryEntity->setId(Uuid::randomHex());
        $deliveryEntity->setStateId(Uuid::randomHex());

        $deliveries = new OrderDeliveryCollection([$deliveryEntity]);

        $orderEntity = $this->orderEntity();
        $orderEntity->setDeliveries($deliveries);
        $cart = $this->getCart();

        $entityRepository = $this->createMock(EntityRepository::class);
        $entityRepository->method('search')->willReturnOnConsecutiveCalls(
            new EntitySearchResult('order', 1, new OrderCollection([$orderEntity]), null, new Criteria()$this->salesChannelContext->getContext()),
        );

        $entityRepository
            
'city' => 'billing-address-city',
                'countryId' => 'billing-address-country-id',
                'firstName' => 'billing-address-first-name',
                'lastName' => 'billing-address-last-name',
                'salutationId' => 'billing-address-salutation-id',
                'street' => 'billing-address-street',
                'zipcode' => 'billing-address-zipcode',
            ]),
            'stateId' => '',
        ]);

        return new OrderDeliveryCollection([$delivery1$delivery2]);
    }
}
Home | Imprint | This part of the site doesn't use cookies.