$packages =
$packager->
getMatchingItems($discount,
$cart,
$context);
$ids =
$packages->
first()?->
getMetaData()->
map(fn (LineItemQuantity
$item) =>
$item->
getLineItemId());
static::
assertEquals($expected,
$ids);
} public static function buildPackagesProvider(): \Generator
{ $stackable =
new LineItem('stackable', LineItem::PRODUCT_LINE_ITEM_TYPE, null, 1
);
$stackable->
setPrice(new CalculatedPrice(100, 100,
new CalculatedTaxCollection(),
new TaxRuleCollection()));
$stackable->
setStackable(true
);
$other =
new LineItem('other', LineItem::PRODUCT_LINE_ITEM_TYPE, null, 2
);
$other->
setPrice(new CalculatedPrice(100, 100,
new CalculatedTaxCollection(),
new TaxRuleCollection()));
$other->
setStackable(true
);
$none =
new LineItem('none', LineItem::PRODUCT_LINE_ITEM_TYPE, null, 1
);
$none->
setPrice(new CalculatedPrice(100, 100,
new CalculatedTaxCollection(),
new TaxRuleCollection()));
$none->
setStackable(false
);
$credit =
new LineItem('credit', LineItem::CREDIT_LINE_ITEM_TYPE, null, 1
);
$credit->
setPrice(new CalculatedPrice(100, 100,
new CalculatedTaxCollection(),
new TaxRuleCollection()));