/** * Test add coupon by code * * @covers addCouponByCode */ public function testAddCoupon() { $cart = $this->prophesize('Elcodi\\Component\\Cart\\Entity\\Interfaces\\CartInterface'); $coupon = $this->prophesize('Elcodi\\Component\\Coupon\\Entity\\Interfaces\\CouponInterface'); $this->cartCouponEventDispatcher->dispatchCartCouponOnApplyEvent(Argument::any(), Argument::any())->shouldBeCalled(); $cartCouponManager = $this->createCartCouponManagerInstance(); $cartCouponManager->addCoupon($cart->reveal(), $coupon->reveal()); }
/** * Adds a Coupon to a Cart and recalculates the Cart Totals. * * @param CartInterface $cart Cart * @param CouponInterface $coupon The coupon to add * * @throws AbstractCouponException * * @return $this Self object */ public function addCoupon(CartInterface $cart, CouponInterface $coupon) { $this->cartCouponEventDispatcher->dispatchCartCouponOnApplyEvent($cart, $coupon); return $this; }