function it_decrements_a_usage_of_promotions_applied_on_order(OrderInterface $order, PromotionInterface $firstPromotion, PromotionInterface $secondPromotion) { $order->getPromotions()->willReturn([$firstPromotion, $secondPromotion]); $firstPromotion->decrementUsed()->shouldBeCalled(); $secondPromotion->decrementUsed()->shouldBeCalled(); $this->decrement($order); }
function it_decrements_promotion_usage_if_promotion_was_used(OrderInterface $order, PromotionInterface $promotion) { $order->getPromotions()->willReturn([$promotion]); $promotion->getUsed()->willReturn(5); $promotion->setUsed(4)->shouldBeCalled(); $this->decrementPromotionUsage($order); }
/** * {@inheritdoc} */ public function decrement(OrderInterface $order) { foreach ($order->getPromotions() as $promotion) { $promotion->decrementUsed(); } $promotionCoupon = $order->getPromotionCoupon(); if (null !== $promotionCoupon) { $promotionCoupon->decrementUsed(); } }
/** * {@inheritdoc} */ public function decrement(OrderInterface $order) { foreach ($order->getPromotions() as $promotion) { $promotion->decrementUsed(); } }
/** * @param OrderInterface $order */ public function decrementPromotionUsage(OrderInterface $order) { foreach ($order->getPromotions() as $promotion) { $promotion->setUsed($promotion->getUsed() - 1); } }