/**
  * {@inheritdoc}
  */
 protected function isCouponEligible(PromotionInterface $promotion, PromotionCouponAwareSubjectInterface $subject)
 {
     $coupon = $subject->getPromotionCoupon();
     if (null === $coupon || $promotion !== $coupon->getPromotion()) {
         return false;
     }
     return $this->isCouponEligibleToLimit($coupon, $subject->getCustomer());
 }
 /**
  * @param PromotionInterface $promotion
  * @param PromotionCouponAwareSubjectInterface $subject
  *
  * @return bool
  */
 protected function isCouponEligible(PromotionInterface $promotion, PromotionCouponAwareSubjectInterface $subject)
 {
     $coupon = $subject->getPromotionCoupon();
     return null !== $coupon && $promotion === $coupon->getPromotion();
 }
 /**
  * @param PromotionInterface $promotion
  * @param PromotionCouponAwareSubjectInterface $subject
  *
  * @return bool
  */
 protected function isCouponEligible(PromotionInterface $promotion, PromotionCouponAwareSubjectInterface $subject)
 {
     return $promotion === $subject->getPromotionCoupon()->getPromotion();
 }
 function it_recognizes_subject_as_eligible_if_coupon_code_match($dispatcher, PromotionCouponAwareSubjectInterface $subject, PromotionInterface $promotion, CouponInterface $coupon)
 {
     $subject->getPromotionCoupon()->willReturn($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);
 }
 function it_returns_false_if_subject_has_no_coupon($eventDispatcher, PromotionInterface $promotion, PromotionCouponAwareSubjectInterface $subject)
 {
     $subject->getPromotionCoupon()->willReturn(null);
     $eventDispatcher->dispatch(SyliusPromotionEvents::COUPON_NOT_ELIGIBLE, Argument::type(GenericEvent::class))->shouldNotBeCalled();
     $this->isEligible($subject, $promotion)->shouldReturn(false);
 }