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);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function removeCoupon(CouponInterface $coupon)
 {
     $coupon->setPromotion(null);
     $this->coupons->removeElement($coupon);
     return $this;
 }
Пример #3
0
 function it_throws_exception_when_a_coupon_is_not_found_but_it_should_exist(RepositoryInterface $couponRepository, CouponInterface $coupon)
 {
     $coupon->getId()->willReturn(5);
     $couponRepository->find(5)->willReturn(null);
     $this->shouldThrow(FailureException::class)->during('couponShouldStillExistInTheRegistry', [$coupon]);
 }
 function it_should_transform_coupon_into_its_code(CouponInterface $coupon)
 {
     $coupon->getCode()->willReturn('C123');
     $this->transform($coupon)->shouldReturn('C123');
 }
Пример #5
0
 /**
  * @Given /^the (coupon "[^"]+") was used up to its usage limit$/
  */
 public function theCouponWasUsed(CouponInterface $coupon)
 {
     $coupon->setUsed($coupon->getUsageLimit());
     $this->objectManager->flush();
 }
Пример #6
0
 /**
  * @Then /^([^"]+) should still exist in the registry$/
  */
 public function couponShouldStillExistInTheRegistry(CouponInterface $coupon)
 {
     Assert::notNull($this->couponRepository->find($coupon->getId()), sprintf('The coupon with id %s should exist', $coupon->getId()));
 }
Пример #7
0
 /**
  * @Then /^([^"]+) should still exist in the registry$/
  */
 public function couponShouldStillExistInTheRegistry(CouponInterface $coupon)
 {
     expect($this->couponRepository->find($coupon->getId()))->toNotBe(null);
 }
Пример #8
0
 function it_gets_coupon_by_its_code(RepositoryInterface $couponRepository, CouponInterface $coupon)
 {
     $coupon->getCode()->willReturn('BEST-CODE');
     $couponRepository->findOneBy(['code' => 'BEST-CODE'])->willReturn($coupon);
     $this->getCouponByCode('BEST-CODE');
 }
 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);
 }
Пример #10
0
 function it_increments_coupon_usage_if_coupon_was_set(OrderInterface $order, CouponInterface $coupon)
 {
     $order->getPromotionCoupons()->willReturn([$coupon]);
     $coupon->incrementUsed()->shouldBeCalled();
     $this->incrementCouponUsage($order);
 }