public function testFind() { $code = '20PCT'; $name = '20% Off orders over $100'; $value = 20; $minOrderValue = 10000; $maxOrderValue = 100000; $promotionType = PromotionType::fixed(); $originalCoupon = new Coupon($code); $originalCoupon->setName($name); $originalCoupon->setValue($value); $originalCoupon->setType($promotionType); $originalCoupon->setMinOrderValue($minOrderValue); $originalCoupon->setMaxOrderValue($maxOrderValue); $originalCoupon->setFlagFreeShipping(true); $originalCoupon->setCanCombineWithOtherCoupons(true); $this->persistEntityAndFlushClear($originalCoupon); $this->setCountLogger(); $coupon = $this->couponRepository->findOneById($originalCoupon->getId()); $this->assertEquals($originalCoupon->getId(), $coupon->getId()); $this->assertSame($code, $coupon->getCode()); $this->assertSame($name, $coupon->getName()); $this->assertSame($value, $coupon->getValue()); $this->assertSame($minOrderValue, $coupon->getMinOrderValue()); $this->assertSame($maxOrderValue, $coupon->getMaxOrderValue()); $this->assertTrue($coupon->getType()->isFixed()); $this->assertTrue($coupon->getFlagFreeShipping()); $this->assertTrue($coupon->getCanCombineWithOtherCoupons()); $this->assertSame(1, $this->getTotalQueries()); }
/** * @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); }
/** * @param UuidInterface $id * @return Coupon * @throws EntityNotFoundException */ public function findOneById(UuidInterface $id) { return $this->couponRepository->findOneById($id); }