public function setId(UuidInterface $uuid = null) { if ($uuid === null) { $uuid = Uuid::uuid4(); } $this->id = $uuid; }
/** * @param string $name * @param string $description * @param int $sortOrder * @param int $textOptionTypeId */ public function __construct($name, $description, $sortOrder, $textOptionTypeId) { $this->textOptionId = Uuid::uuid4(); $this->name = (string) $name; $this->description = (string) $description; $this->sortOrder = (int) $sortOrder; $this->textOptionType = TextOptionType::createById($textOptionTypeId); }
public function testSerialize() { $uuid1 = Uuid::fromString(self::UUID4_STRING); $serializedString = $uuid1->serialize(); $uuid2 = Uuid::uuid4(); $uuid2->unserialize($serializedString); $this->assertTrue($uuid1->equals($uuid2)); }
/** * @param string $cartId * @param string $userIdS * @param string $ip4 * @param CreditCardDTO $creditCardDTO * @param OrderAddressDTO $shippingAddressDTO * @param OrderAddressDTO $billingAddressDTO */ public function __construct($cartId, $userIdS, $ip4, CreditCardDTO $creditCardDTO, OrderAddressDTO $shippingAddressDTO, OrderAddressDTO $billingAddressDTO) { $this->orderId = Uuid::uuid4(); $this->cartId = Uuid::fromString($cartId); $this->userId = Uuid::fromString($userIdS); $this->ip4 = (string) $ip4; $this->creditCardDTO = $creditCardDTO; $this->shippingAddressDTO = $shippingAddressDTO; $this->billingAddressDTO = $billingAddressDTO; }
public function __construct(RepositoryFactory $repositoryFactory, CartCalculatorInterface $cartCalculator, EventDispatcherInterface $eventDispatcher, PaymentGatewayInterface $paymentGateway, ShipmentGatewayInterface $shipmentGateway, FileManagerInterface $fileManager) { $this->repositoryFactory = $repositoryFactory; $this->cartCalculator = $cartCalculator; $this->eventDispatcher = $eventDispatcher; $this->paymentGateway = $paymentGateway; $this->shipmentGateway = $shipmentGateway; $this->fileManager = $fileManager; $this->holdLocationId = Uuid::uuid4(); }
/** * @param int $promotionTypeId * @param int $value * @param bool $reducesTaxSubtotal * @param int $maxRedemptions * @param DateTime $startDate * @param DateTime $endDate * @param string $productId * @param int $quantity * @param bool $flagApplyCatalogPromotions */ public function __construct($promotionTypeId, $value, $reducesTaxSubtotal, $maxRedemptions, $startDate, $endDate, $productId, $quantity, $flagApplyCatalogPromotions) { $this->productQuantityDiscountId = Uuid::uuid4(); $this->promotionTypeId = $promotionTypeId; $this->value = $value; $this->reducesTaxSubtotal = $reducesTaxSubtotal; $this->productId = Uuid::fromString($productId); $this->quantity = $quantity; $this->flagApplyCatalogPromotions = $flagApplyCatalogPromotions; }
/** * @param string $remoteIp4 * @param string|null $userId * @param string|null $sessionId */ public function __construct($remoteIp4, $userId = null, $sessionId = null) { $this->cartId = Uuid::uuid4(); $this->remoteIp4 = (string) $remoteIp4; if ($userId !== null) { $this->userId = Uuid::fromString($userId); } if ($sessionId !== null) { $this->sessionId = (string) $sessionId; } }
/** * @param string $name * @param int $promotionTypeId * @param int $value * @param bool $reducesTaxSubtotal * @param int $maxRedemptions * @param DateTime $startDate * @param DateTime $endDate * @param string|null $tagId */ public function __construct($name, $promotionTypeId, $value, $reducesTaxSubtotal, $maxRedemptions, $startDate, $endDate, $tagId = null) { $this->catalogPromotionId = Uuid::uuid4(); $this->name = $name; $this->promotionTypeId = $promotionTypeId; $this->value = $value; $this->reducesTaxSubtotal = $reducesTaxSubtotal; $this->maxRedemptions = $maxRedemptions; $this->startDate = $startDate; $this->endDate = $endDate; if ($tagId !== null) { $this->tagId = Uuid::fromString($tagId); } }
/** * @param string $fileExtension * @param string $basePath * @param int $imageType * @param string $mimeType * @param int $width * @param int $height * @param string|null $uriPrefix */ public function __construct($fileExtension, $basePath, $imageType, $mimeType, $width, $height, $uriPrefix = null) { $this->id = Uuid::uuid4(); $this->baseFileName = $this->id->getHex(); $this->subPath = $this->buildSubPath(); $this->fileExtension = (string) $fileExtension; $this->basePath = (string) $basePath; $this->imageType = (int) $imageType; $this->mimeType = (string) $mimeType; $this->width = (int) $width; $this->height = (int) $height; if ($uriPrefix !== null) { $this->uriPrefix = (string) $uriPrefix; } }
/** * CreateCouponCommand constructor. * @param string $code * @param bool $flagFreeShipping * @param int $minOrderValue * @param int $maxOrderValue * @param bool $canCombineWithOtherCoupons * @param string $name * @param int $promotionTypeId * @param int $value * @param bool $reducesTaxSubtotal * @param int $maxRedemptions * @param DateTime $startDate * @param DateTime $endDate */ public function __construct($code, $flagFreeShipping, $minOrderValue, $maxOrderValue, $canCombineWithOtherCoupons, $name, $promotionTypeId, $value, $reducesTaxSubtotal, $maxRedemptions, $startDate, $endDate) { $this->couponId = Uuid::uuid4(); $this->code = $code; $this->flagFreeShipping = $flagFreeShipping; $this->minOrderValue = $minOrderValue; $this->maxOrderValue = $maxOrderValue; $this->canCombineWithOtherCoupons = $canCombineWithOtherCoupons; $this->name = $name; $this->promotionTypeId = $promotionTypeId; $this->value = $value; $this->reducesTaxSubtotal = $reducesTaxSubtotal; $this->maxRedemptions = $maxRedemptions; $this->startDate = $startDate; $this->endDate = $endDate; }
/** * @param string $cartId * @param string $productId * @param int $quantity * @param string[]|null $optionProductIds * @param string[]|null $optionValuesIds * @param TextOptionValueDTO[]|null $textOptionValueDTOs */ public function __construct($cartId, $productId, $quantity, array $optionProductIds = null, array $optionValuesIds = null, array $textOptionValueDTOs = null) { $this->cartItemId = Uuid::uuid4(); $this->cartId = Uuid::fromString($cartId); $this->productId = Uuid::fromString($productId); $this->quantity = (int) $quantity; if ($optionProductIds !== null) { $this->setOptionProductIds($optionProductIds); } if ($optionValuesIds !== null) { $this->setOptionValueIds($optionValuesIds); } if ($textOptionValueDTOs !== null) { $this->setTextOptionValueDTOs($textOptionValueDTOs); } }
public function __construct(UserDTO $userDTO) { $this->userId = Uuid::uuid4(); $this->userDTO = $userDTO; }
public function __construct(OptionDTO $optionDTO) { $this->optionId = Uuid::uuid4(); $this->optionDTO = $optionDTO; }
public function getId() { return Uuid::uuid4(); }
public function testCreateOrderFromCart() { $cart = $this->getPersistedCart(); $orderId = Uuid::uuid4(); $order = $this->orderService->createOrderFromCart($orderId, $cart->getUser(), $cart, $this->getCartCalculator(), '10.0.0.1', $this->dummyData->getOrderAddress(), $this->dummyData->getOrderAddress(), $this->dummyData->getCreditCard()); $this->assertTrue($order instanceof Order); $this->assertTrue($order->getPayments()[0] instanceof CreditPayment); // TODO: Test reserveProductsFromInventory /** @var OrderCreatedFromCartEvent $event */ $event = $this->fakeEventDispatcher->getDispatchedEvents(OrderCreatedFromCartEvent::class)[0]; $this->assertTrue($event instanceof OrderCreatedFromCartEvent); $this->assertSame($order->getId(), $event->getOrderId()); }
public function testCreateFromCart() { $productX = $this->dummyData->getProduct('PROD-X'); $productY = $this->dummyData->getProduct('PROD-X'); $cartPriceRuleItem = $this->dummyData->getCartPriceRuleProductItem($productX); $cartPriceRuleDiscount = $this->dummyData->getCartPriceRuleDiscount($productY); $cartPriceRule = $this->dummyData->getCartPriceRule(); $cartPriceRule->setName('Buy X get Y FREE'); $cartPriceRule->addItem($cartPriceRuleItem); $cartPriceRule->addDiscount($cartPriceRuleDiscount); $catalogPromotion = $this->dummyData->getCatalogPromotion(); $catalogPromotion->setName('10% OFF Site Wide Catalog Promotion'); $productQuantityDiscount = $this->dummyData->getProductQuantityDiscount($productX); $pricing = $this->dummyData->getPricing([$catalogPromotion], [$productQuantityDiscount]); $pricing->setCartPriceRules([$cartPriceRule]); $cartCalculator = $this->dummyData->getCartCalculator($pricing); $user = $this->dummyData->getUser(); $coupon = $this->dummyData->getCoupon(); $taxRate = $this->dummyData->getTaxRate(); $shipmentRate = $this->dummyData->getShipmentRate(1000); $cartItem1 = $this->dummyData->getCartItem($productX); $cartItem2 = $this->dummyData->getCartItem($productY); $cart = $this->dummyData->getCart([$cartItem1, $cartItem2]); $cart->setUser($user); $cart->addCoupon($coupon); $cart->setTaxRate($taxRate); $cart->setShipmentRate($shipmentRate); $orderId = Uuid::uuid4(); $order = Order::fromCart($orderId, $user, $cart, $cartCalculator, '10.0.0.1'); $this->assertTrue($order instanceof Order); $this->assertSame('10.0.0.1', $order->getIp4()); $this->assertSame($user, $order->getUser()); $this->assertSame($coupon, $order->getCoupons()[0]); $this->assertSame($taxRate, $order->getTaxRate()); $this->assertSame($shipmentRate, $order->getShipmentRate()); $orderItem1 = $order->getOrderItems()[0]; $this->assertEntitiesEqual($catalogPromotion, $orderItem1->getCatalogPromotions()[0]); $this->assertEntitiesEqual($productQuantityDiscount, $orderItem1->getProductQuantityDiscounts()[0]); $this->assertSame('10% OFF Site Wide Catalog Promotion, Buy 1 or more for 5% off', $orderItem1->getDiscountNames()); $this->assertEntitiesEqual($cartPriceRule, $order->getCartPriceRules()[0]); $this->assertSame('Buy X get Y FREE, 20% OFF Test Coupon', $order->getDiscountNames()); }
public function __construct(TagDTO $tagDTO) { $this->tagId = Uuid::uuid4(); $this->tagDTO = $tagDTO; }
public function testAddItem() { $product = $this->dummyData->getProduct(); $this->productRepository->shouldReceive('findOneById')->with($product->getId())->andReturn($product)->once(); $cart = $this->getCartThatRepositoryWillFind(); $this->cartRepositoryShouldUpdateOnce($cart); $cartItemId = Uuid::uuid4(); $cartItem = $this->cartService->addItem($cartItemId, $cart->getId(), $product->getid()); $this->assertEntitiesEqual($cartItem, $cart->getCartItems()[0]); $this->assertSame(null, $cart->getShipmentRate()); }
public function __construct(ProductDTO $productDTO) { $this->productId = Uuid::uuid4(); $this->productDTO = $productDTO; }