/**
  * {@inheritdoc}
  */
 public function isEligible(PromotionSubjectInterface $promotionSubject, PromotionInterface $promotion)
 {
     $now = new \DateTime();
     $startsAt = $promotion->getStartsAt();
     if (null !== $startsAt && $now < $startsAt) {
         return false;
     }
     $endsAt = $promotion->getEndsAt();
     if (null !== $endsAt && $now > $endsAt) {
         return false;
     }
     return true;
 }
 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 the current is between promotion limits.
  *
  * @param PromotionInterface $promotion
  *
  * @return bool
  */
 protected function isEligibleToDates(PromotionInterface $promotion)
 {
     $now = new \DateTime();
     if (null !== ($startsAt = $promotion->getStartsAt())) {
         if ($now < $startsAt) {
             return false;
         }
     }
     if (null !== ($endsAt = $promotion->getEndsAt())) {
         if ($now > $endsAt) {
             return false;
         }
     }
     return true;
 }
 function it_returns_true_if_promotion_dates_are_not_specified(PromotionSubjectInterface $promotionSubject, PromotionInterface $promotion)
 {
     $promotion->getStartsAt()->willReturn(null);
     $promotion->getEndsAt()->willReturn(null);
     $this->isEligible($promotionSubject, $promotion)->shouldReturn(true);
 }