コード例 #1
0
 /**
  * Test getCartCoupons
  *
  * @covers getCartCoupons
  */
 public function testGetCouponsCartWithId()
 {
     $cart = $this->prophesize('Elcodi\\Component\\Cart\\Entity\\Interfaces\\CartInterface');
     $cart->getId()->willReturn(1);
     $this->cartCouponRepository->findCartCouponsByCart(Argument::any())->shouldBeCalled();
     $cartCouponManager = $this->createCartCouponManagerInstance();
     $cartCouponManager->getCartCoupons($cart->reveal());
 }
コード例 #2
0
 /**
  * Get CartCoupon instances assigned to current Cart.
  *
  * @param CartInterface $cart Cart
  *
  * @return CartCouponInterface[] CartCoupons
  */
 public function getCartCoupons(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->findCartCouponsByCart($cart);
 }