OrderLineItemDownloadCollection example

$orderLineItem->setType('order-line-item-type');
        $orderLineItem->setLabel('order-line-item-label');
        $orderLineItem->setGood(true);
        $orderLineItem->setRemovable(false);
        $orderLineItem->setStackable(true);

        if ($toManipulate === 'order-add-line-item-download') {
            $orderLineItemDownload = new OrderLineItemDownloadEntity();
            $orderLineItemDownload->setId(Uuid::randomHex());
            $orderLineItemDownload->setMediaId(Uuid::randomHex());

            $orderLineItemDownloadCollection = new OrderLineItemDownloadCollection();
            $orderLineItemDownloadCollection->add($orderLineItemDownload);
            $orderLineItem->setDownloads($orderLineItemDownloadCollection);
        }

        $orderLineItemCollection = new OrderLineItemCollection();
        $orderLineItemCollection->add($orderLineItem);

        // Order delivery position         $orderDeliveryPositionCollection = new OrderDeliveryPositionCollection();
        $orderDeliveryPosition = new OrderDeliveryPositionEntity();
        $orderDeliveryPosition->setId('order-delivery-position-id-1');
        

        $filterId = Uuid::randomHex();

        $downloadA = new OrderLineItemDownloadEntity();
        $downloadA->setId(Uuid::randomHex());
        $downloadA->setOrderLineItemId(Uuid::randomHex());

        $downloadB = new OrderLineItemDownloadEntity();
        $downloadB->setId(Uuid::randomHex());
        $downloadB->setOrderLineItemId(Uuid::randomHex());

        $collection = new OrderLineItemDownloadCollection([$downloadA$downloadB]);

        static::assertEquals(0, $collection->filterByOrderLineItemId($filterId)->count());

        $downloadA->setOrderLineItemId($filterId);

        static::assertEquals(1, $collection->filterByOrderLineItemId($filterId)->count());
    }
}
$order = new OrderEntity();

        $lineItem = new OrderLineItemEntity();
        $lineItem->setId(Uuid::randomHex());
        $lineItem->setGood(true);
        $lineItem->setStates([State::IS_DOWNLOAD]);

        $downloadId = Uuid::randomHex();
        $download = new OrderLineItemDownloadEntity();
        $download->setId($downloadId);

        $lineItem->setDownloads(new OrderLineItemDownloadCollection([$download]));

        $order->setLineItems(new OrderLineItemCollection([$lineItem]));

        yield 'grant access for order with downloadable line items' => [
            $order,
            [
                [
                    'id' => $downloadId,
                    'accessGranted' => true,
                ],
            ],
        ];
Home | Imprint | This part of the site doesn't use cookies.