static::
assertInstanceOf(AndRule::
class,
$rule->
getPayload());
/** @var AndRule $andRule */
$andRule =
$rule->
getPayload();
static::
assertInstanceOf(PromotionValueRule::
class,
$andRule->
getRules()[0
]);
$filterRule = ReflectionHelper::
getProperty(PromotionValueRule::
class, 'filter'
)->
getValue($andRule->
getRules()[0
]);
static::
assertInstanceOf(AndRule::
class,
$filterRule);
static::
assertInstanceOf(PromotionCodeOfTypeRule::
class,
$filterRule->
getRules()[0
]);
} public function testFilter(): void
{ $item =
$this->
createLineItemWithPrice(LineItem::PROMOTION_LINE_ITEM_TYPE, -40
)->
setPayloadValue('promotionCodeType', 'fixed'
);
$item2 =
$this->
createLineItemWithPrice(LineItem::PROMOTION_LINE_ITEM_TYPE, -100
)->
setPayloadValue('promotionCodeType', 'global'
);
$cart =
$this->
createCart(new LineItemCollection([$item,
$item2]));
$this->
assertRuleMatches($cart);
} public function testFilterNested(): void
{ $item =
$this->
createLineItemWithPrice(LineItem::PROMOTION_LINE_ITEM_TYPE, -40
)->
setPayloadValue('promotionCodeType', 'fixed'
);
$item2 =
$this->
createLineItemWithPrice(LineItem::PROMOTION_LINE_ITEM_TYPE, -100
)->
setPayloadValue('promotionCodeType', 'global'
);