コード例 #1
0
 public function testAllGetCouponsByIds()
 {
     $coupon1 = $this->dummyData->getCoupon();
     $this->couponRepository->shouldReceive('getAllCouponsByIds')->with([$coupon1->getId()], null)->andReturn([$coupon1])->once();
     $coupons = $this->couponService->getAllCouponsByIds([$coupon1->getId()]);
     $this->assertSame($coupon1, $coupons[0]);
 }
コード例 #2
0
ファイル: CartService.php プロジェクト: inklabs/kommerce-core
 /**
  * @param UuidInterface $cartId
  * @param UuidInterface $couponId
  */
 public function removeCoupon(UuidInterface $cartId, UuidInterface $couponId)
 {
     $cart = $this->cartRepository->findOneById($cartId);
     $coupon = $this->couponRepository->findOneById($couponId);
     $cart->removeCoupon($coupon);
     $this->cartRepository->update($cart);
 }
コード例 #3
0
 public function testRemoveCoupon()
 {
     $coupon = $this->dummyData->getCoupon();
     $cart = $this->getCartThatRepositoryWillFind();
     $cart->addCoupon($coupon);
     $this->cartRepositoryShouldUpdateOnce($cart);
     $this->couponRepository->shouldReceive('findOneById')->with($coupon->getId())->andReturn($coupon);
     $this->cartService->removeCoupon($cart->getId(), $coupon->getId());
     $this->assertCount(0, $cart->getCoupons());
 }
コード例 #4
0
 public function testGetAllCouponsByIds()
 {
     $originalCoupon = $this->setupCoupon();
     $coupons = $this->couponRepository->getAllCouponsByIds([$originalCoupon->getId()]);
     $this->assertEquals($originalCoupon->getId(), $coupons[0]->getId());
 }
コード例 #5
0
 /**
  * @param UuidInterface[] $couponIds
  * @param Pagination $pagination
  * @return Coupon[]
  */
 public function getAllCouponsByIds($couponIds, Pagination &$pagination = null)
 {
     return $this->couponRepository->getAllCouponsByIds($couponIds, $pagination);
 }