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]); }
/** * @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); }
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()); }
public function testGetAllCouponsByIds() { $originalCoupon = $this->setupCoupon(); $coupons = $this->couponRepository->getAllCouponsByIds([$originalCoupon->getId()]); $this->assertEquals($originalCoupon->getId(), $coupons[0]->getId()); }
/** * @param UuidInterface[] $couponIds * @param Pagination $pagination * @return Coupon[] */ public function getAllCouponsByIds($couponIds, Pagination &$pagination = null) { return $this->couponRepository->getAllCouponsByIds($couponIds, $pagination); }