Example #1
0
 /**
  * {@inheritdoc}
  */
 public function createForPromotion($promotionId)
 {
     if (null === ($promotion = $this->promotionRepository->find($promotionId))) {
         throw new \InvalidArgumentException(sprintf('Promotion with id "%s" does not exist.', $promotionId));
     }
     $coupon = $this->factory->createNew();
     $coupon->setPromotion($promotion);
     return $coupon;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function createForPromotion($promotionId)
 {
     /** @var PromotionInterface $promotion */
     Assert::notNull($promotion = $this->promotionRepository->find($promotionId), sprintf('Promotion with id %s does not exist.', $promotionId));
     Assert::true($promotion->isCouponBased(), sprintf('Promotion with name %s is not coupon based.', $promotion->getName()));
     $coupon = $this->factory->createNew();
     $coupon->setPromotion($promotion);
     return $coupon;
 }
Example #3
0
 function it_creates_a_coupon_and_assigns_a_promotion_to_id(FactoryInterface $factory, PromotionRepositoryInterface $promotionRepository, PromotionInterface $promotion, CouponInterface $coupon)
 {
     $factory->createNew()->willReturn($coupon);
     $promotionRepository->find(13)->willReturn($promotion);
     $coupon->setPromotion($promotion)->shouldBeCalled();
     $this->createForPromotion(13)->shouldReturn($coupon);
 }
 /**
  * @Then promotion :promotion should still exist in the registry
  */
 public function promotionShouldStillExistInTheRegistry(PromotionInterface $promotion)
 {
     Assert::notNull($this->promotionRepository->find($promotion->getId()));
 }
Example #5
0
 /**
  * @Then promotion :promotion should still exist in the registry
  */
 public function promotionShouldStillExistInTheRegistry(PromotionInterface $promotion)
 {
     expect($this->promotionRepository->find($promotion->getId()))->toNotBe(null);
 }