/**
  * Test checkDuplicates with duplication
  *
  * @covers checkDuplicates
  * @dataProvider dataCheckDuplicates
  */
 public function testCheckDuplicates(CartCouponInterface $cartCoupon = null, $expectsException = true)
 {
     $cartCouponRepository = $this->prophesize('Elcodi\\Component\\CartCoupon\\Repository\\CartCouponRepository');
     $cart = $this->prophesize('Elcodi\\Component\\Cart\\Entity\\Interfaces\\CartInterface')->reveal();
     $coupon = $this->prophesize('Elcodi\\Component\\Coupon\\Entity\\Interfaces\\CouponInterface')->reveal();
     $cartCouponRepository->findOneBy(['cart' => $cart, 'coupon' => $coupon])->willReturn($cartCoupon);
     $duplicatedCouponChecker = new DuplicatedCouponValidator($cartCouponRepository->reveal());
     try {
         $duplicatedCouponChecker->validateDuplicatedCoupon($cart, $coupon);
     } catch (CouponAlreadyAppliedException $exception) {
         if (!$expectsException) {
             throw $exception;
         }
     }
 }
 /**
  * Check if this coupon is already applied to the cart
  *
  * @param CartCouponOnApplyEvent $event Event
  *
  * @throws CouponAlreadyAppliedException Coupon already applied
  */
 public function validateDuplicatedCoupon(CartCouponOnApplyEvent $event)
 {
     $this->duplicatedCouponValidator->validateDuplicatedCoupon($event->getCart(), $event->getCoupon());
 }