function it_throws_exception_when_a_coupon_is_found_but_it_should_not_exist(CouponInterface $coupon, RepositoryInterface $couponRepository) { $coupon->getCode()->willReturn('christmas_coupon'); $couponRepository->findOneBy(['code' => 'christmas_coupon'])->willReturn($coupon); $this->shouldThrow(NotEqualException::class)->during('couponShouldNotExistInTheRegistry', [$coupon]); }
function it_should_transform_coupon_into_its_code(CouponInterface $coupon) { $coupon->getCode()->willReturn('C123'); $this->transform($coupon)->shouldReturn('C123'); }
/** * @Then /^(this coupon) should no longer exist in the coupon registry$/ */ public function couponShouldNotExistInTheRegistry(CouponInterface $coupon) { expect($this->couponRepository->findOneBy(['code' => $coupon->getCode()]))->toBe(null); }
/** * @Then /^(this coupon) should no longer exist in the coupon registry$/ */ public function couponShouldNotExistInTheRegistry(CouponInterface $coupon) { Assert::null($this->couponRepository->findOneBy(['code' => $coupon->getCode()]), sprintf('The coupon with code %s should not exist', $coupon->getCode())); }
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'); }