Example #1
0
 /**
  * @Transform /^promotion "([^"]+)"$/
  * @Transform /^"([^"]+)" promotion$/
  * @Transform :promotion
  */
 public function getPromotionByName($promotionName)
 {
     $promotion = $this->promotionRepository->findOneBy(['name' => $promotionName]);
     if (null === $promotion) {
         throw new \InvalidArgumentException(sprintf('Promotion with name "%s" does not exist in the promotion repository.', $promotionName));
     }
     return $promotion;
 }
 function it_throws_exception_when_promotion_with_given_name_was_not_found(PromotionRepositoryInterface $promotionRepository)
 {
     $promotionRepository->findOneBy(['name' => 'Wrong Promotion'])->willReturn(null);
     $this->shouldThrow(\InvalidArgumentException::class)->during('getPromotionByName', ['Wrong Promotion']);
 }
 /**
  * @Then /^(this promotion) should no longer exist in the promotion registry$/
  */
 public function promotionShouldNotExistInTheRegistry(PromotionInterface $promotion)
 {
     Assert::null($this->promotionRepository->findOneBy(['code' => $promotion->getCode()]));
 }
Example #4
0
 /**
  * @Then /^(this promotion) should no longer exist in the promotion registry$/
  */
 public function promotionShouldNotExistInTheRegistry(PromotionInterface $promotion)
 {
     expect($this->promotionRepository->findOneBy(['code' => $promotion->getCode()]))->toBe(null);
 }
 /**
  * @Transform /^promotion "([^"]+)"$/
  * @Transform /^"([^"]+)" promotion$/
  * @Transform :promotion
  */
 public function getPromotionByName($promotionName)
 {
     $promotion = $this->promotionRepository->findOneBy(['name' => $promotionName]);
     Assert::notNull($promotion, sprintf('Promotion with name "%s" does not exist', $promotionName));
     return $promotion;
 }