$optionTwoId = Uuid::
randomHex();
$orderLineItemCollection =
new OrderLineItemCollection( [ $this->
buildOrderLineItemEntity($containerId, LineItem::CUSTOM_LINE_ITEM_TYPE, null, 3
),
$this->
buildOrderLineItemEntity($productId, LineItem::PRODUCT_LINE_ITEM_TYPE,
$containerId, 3
),
$this->
buildOrderLineItemEntity($optionOneId, LineItem::CUSTOM_LINE_ITEM_TYPE,
$containerId, 3
),
$this->
buildOrderLineItemEntity($optionTwoId, LineItem::CUSTOM_LINE_ITEM_TYPE,
$containerId, 3
),
] );
$nestedCollection = LineItemTransformer::
transformFlatToNested($orderLineItemCollection);
static::
assertCount(1,
$nestedCollection);
$lineItem =
$nestedCollection->
first();
static::
assertInstanceOf(LineItem::
class,
$lineItem);
static::
assertSame(3,
$lineItem->
getQuantity());
$childrenCollection =
$lineItem->
getChildren();
static::
assertCount(3,
$childrenCollection);
$productCollection =
$childrenCollection->
filterType(LineItem::PRODUCT_LINE_ITEM_TYPE
);
static::
assertCount(1,
$productCollection);