/** * @param UuidInterface $cartId * @param string $couponCode * @throws EntityNotFoundException */ public function addCouponByCode(UuidInterface $cartId, $couponCode) { $coupon = $this->couponRepository->findOneByCode($couponCode); $cart = $this->cartRepository->findOneById($cartId); $cart->addCoupon($coupon); $this->cartRepository->update($cart); }
public function testFindOneByCodeMissingThrowsException() { $this->setExpectedException(EntityNotFoundException::class, 'Coupon not found'); $this->couponRepository->findOneByCode('xyz'); }