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); }
function it_recognizes_subject_as_not_eligible_if_promotion_subject_is_not_coupon_aware($registry, RuleCheckerInterface $checker, PromotionSubjectInterface $subject, PromotionInterface $promotion, CouponInterface $coupon, RuleInterface $rule) { $promotion->getStartsAt()->willReturn(null); $promotion->getEndsAt()->willReturn(null); $promotion->getUsageLimit()->willReturn(null); $promotion->hasRules()->willReturn(true); $promotion->isCouponBased()->willReturn(true); $coupon->getPromotion()->willReturn($promotion); $registry->get(RuleInterface::TYPE_ITEM_TOTAL)->willReturn($checker); $promotion->getRules()->willReturn([$rule]); $rule->getType()->willReturn(RuleInterface::TYPE_ITEM_TOTAL); $rule->getConfiguration()->willReturn([]); $registry->get(RuleInterface::TYPE_ITEM_TOTAL)->willReturn($checker); $checker->isEligible($subject, [])->willReturn(false); $this->isEligible($subject, $promotion)->shouldReturn(false); }