コード例 #1
0
 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());
 }
コード例 #2
0
 public function handle(CreateCouponCommand $command)
 {
     $coupon = new Coupon($command->getCode(), $command->getCouponId());
     $coupon->setFlagFreeShipping($command->getFlagFreeShipping());
     $coupon->setMinOrderValue($command->getMinOrderValue());
     $coupon->setMaxOrderValue($command->getMaxOrderValue());
     $coupon->setCanCombineWithOtherCoupons($command->canCombineWithOtherCoupons());
     $coupon->setName($command->getName());
     $coupon->setType(PromotionType::createById($command->getPromotionTypeId()));
     $coupon->setValue($command->getValue());
     $coupon->setReducesTaxSubtotal($command->getReducesTaxSubtotal());
     $coupon->setMaxRedemptions($command->getMaxRedemptions());
     $coupon->setStart($command->getStartDate());
     $coupon->setEnd($command->getEndDate());
     $this->couponService->create($coupon);
 }
コード例 #3
0
ファイル: DummyData.php プロジェクト: inklabs/kommerce-core
 public function getCoupon($code = null)
 {
     if ($code === null) {
         $code = uniqid();
     }
     $coupon = new Coupon($code);
     $coupon->setName('20% OFF Test Coupon');
     $coupon->setType(PromotionType::percent());
     $coupon->setValue(20);
     $coupon->setStart(new DateTime('-1 Day'));
     $coupon->setEnd(new DateTime('+1 Day'));
     return $coupon;
 }