/**
  * {@inheritdoc}
  */
 public function isEligible(PromotionInterface $promotion)
 {
     if (null === ($usageLimit = $promotion->getUsageLimit())) {
         return true;
     }
     if ($promotion->getUsed() < $usageLimit) {
         return true;
     }
     return false;
 }
 function it_recognizes_subject_as_eligible_if_coupon_code_match($dispatcher, PromotionCouponsAwareSubjectInterface $subject, PromotionInterface $promotion, CouponInterface $coupon)
 {
     $subject->getPromotionCoupons()->willReturn(array($coupon));
     $promotion->getStartsAt()->willReturn(null);
     $promotion->getEndsAt()->willReturn(null);
     $promotion->getUsageLimit()->willReturn(null);
     $promotion->hasRules()->willReturn(false);
     $promotion->isCouponBased()->willReturn(true);
     $coupon->getPromotion()->willReturn($promotion);
     $dispatcher->dispatch(SyliusPromotionEvents::COUPON_ELIGIBLE, Argument::any())->shouldBeCalled();
     $this->isEligible($subject, $promotion)->shouldReturn(true);
 }
 /**
  * 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);
 }