/** * Test getCartCoupons * * @covers getCoupons */ public function testGetCartCouponsCartWithId() { $cart = $this->prophesize('Elcodi\\Component\\Cart\\Entity\\Interfaces\\CartInterface'); $cart->getId()->willReturn(1); $this->cartCouponRepository->findCouponsByCart(Argument::any())->shouldBeCalled(); $cartCouponManager = $this->createCartCouponManagerInstance(); $cartCouponManager->getCoupons($cart->reveal()); }
/** * Get cart coupon objects. * * @param CartInterface $cart Cart * * @return CouponInterface[] Coupons */ public function getCoupons(CartInterface $cart) { /** * If Cart id is null means that this cart has been generated from * scratch. This also means that it cannot have any Coupon associated. * If is this case, we avoid this lookup. */ if ($cart->getId() === null) { return []; } return $this->cartCouponRepository->findCouponsByCart($cart); }