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 isEligible(PromotionInterface $promotion)
 {
     if (null === ($usageLimit = $promotion->getUsageLimit())) {
         return true;
     }
     if ($promotion->getUsed() < $usageLimit) {
         return true;
     }
     return false;
 }
 /**
  * Checks if promotion usage limit has been reached.
  *
  * @param PromotionInterface $promotion
  *
  * @return bool
  */
 protected function isEligibleToUsageLimit(PromotionInterface $promotion)
 {
     if (null !== ($usageLimit = $promotion->getUsageLimit())) {
         if ($promotion->getUsed() >= $usageLimit) {
             return false;
         }
     }
     return true;
 }
 function it_returns_false_if_usage_limit_has_been_exceeded(PromotionSubjectInterface $promotionSubject, PromotionInterface $promotion)
 {
     $promotion->getUsageLimit()->willReturn(10);
     $promotion->getUsed()->willReturn(15);
     $this->isEligible($promotionSubject, $promotion)->shouldReturn(false);
 }