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()); }
public function testGetNameFixed() { $this->productQuantityDiscount->setType(PromotionType::fixed()); $this->productQuantityDiscount->setQuantity(10); $this->productQuantityDiscount->setValue(500); $this->assertSame('Buy 10 or more for $5.00 off', $this->productQuantityDiscount->getName()); }
public function __construct(UuidInterface $id = null) { $this->setId($id); $this->setCreated(); $this->setType(PromotionType::fixed()); $this->setRedemptions(0); $this->setReducesTaxSubtotal(true); }
public function testCreate() { $catalogPromotion = $this->dummyData->getCatalogPromotion(); $catalogPromotion->setName('20% OFF Everything'); $productQuantityDiscount1 = $this->dummyData->getProductQuantityDiscount(); $productQuantityDiscount1->setType(PromotionType::exact()); $productQuantityDiscount1->setQuantity(1); $productQuantityDiscount1->setValue(100); $product = $this->dummyData->getProduct(); $product->setSku('sku1'); $product->setName('Test Product'); $productQuantityDiscount2 = $this->dummyData->getProductQuantityDiscount(); $productQuantityDiscount2->setType(PromotionType::fixed()); $productQuantityDiscount2->setQuantity(2); $productQuantityDiscount2->setValue(200); $price = $this->dummyData->getPrice(); $price->addCatalogPromotion($catalogPromotion); $price->addProductQuantityDiscount($productQuantityDiscount1); $price->addProductQuantityDiscount($productQuantityDiscount2); $optionProduct = $this->dummyData->getOptionProduct(); $optionProduct->getProduct()->setSku('OP1'); $orderItemOptionProduct = $this->dummyData->getOrderItemOptionProduct($optionProduct); $optionValue = $this->dummyData->getOptionValue(); $optionValue->setSku('OV1'); $orderItemOptionValue = $this->dummyData->getOrderItemOptionValue($optionValue); $orderItemTextOptionValue = $this->dummyData->getOrderItemTextOptionValue(); $order = $this->dummyData->getOrder(); $orderItem = new OrderItem($order); $orderItem->setProduct($product); $orderItem->setQuantity(2); $orderItem->setPrice($price); $orderItem->addOrderItemOptionProduct($orderItemOptionProduct); $orderItem->addOrderItemOptionValue($orderItemOptionValue); $orderItem->addOrderItemTextOptionValue($orderItemTextOptionValue); $this->assertEntityValid($orderItem); $this->assertSame(2, $orderItem->getQuantity()); $this->assertSame('sku1-OP1-OV1', $orderItem->getSku()); $this->assertSame('Test Product', $orderItem->getName()); $this->assertSame('20% OFF Everything, Buy 1 or more for $1.00 each, Buy 2 or more for $2.00 off', $orderItem->getDiscountNames()); $this->assertSame($order, $orderItem->getOrder()); $this->assertSame($product, $orderItem->getProduct()); $this->assertSame($price, $orderItem->getPrice()); $this->assertSame($orderItemOptionProduct, $orderItem->getOrderItemOptionProducts()[0]); $this->assertSame($orderItemOptionValue, $orderItem->getOrderItemOptionValues()[0]); $this->assertSame($orderItemTextOptionValue, $orderItem->getOrderItemTextOptionValues()[0]); $this->assertSame($catalogPromotion, $orderItem->getCatalogPromotions()[0]); $this->assertSame($productQuantityDiscount1, $orderItem->getProductQuantityDiscounts()[0]); }
public function testGetUnitPriceWithFixed() { $this->promotion->setType(PromotionType::fixed()); $this->promotion->setValue(20); $this->assertSame(980, $this->promotion->getUnitPrice(1000)); }
public function testGetters() { $this->assertSame('Fixed', PromotionType::fixed()->getName()); $this->assertSame('Percent', PromotionType::percent()->getName()); $this->assertSame('Exact', PromotionType::exact()->getName()); }