Ejemplo n.º 1
0
 public function __construct(OrderItem $orderItem, DTOBuilderFactoryInterface $dtoBuilderFactory)
 {
     $this->entity = $orderItem;
     $this->dtoBuilderFactory = $dtoBuilderFactory;
     $this->entityDTO = $this->getEntityDTO();
     $this->setId();
     $this->setTime();
     $this->entityDTO->quantity = $this->entity->getQuantity();
     $this->entityDTO->sku = $this->entity->getSku();
     $this->entityDTO->name = $this->entity->getName();
     $this->entityDTO->discountNames = $this->entity->getDiscountNames();
     $this->entityDTO->areAttachmentsEnabled = $this->entity->areAttachmentsEnabled();
     if ($this->entity->getPrice() !== null) {
         $this->entityDTO->price = $this->dtoBuilderFactory->getPriceDTOBuilder($orderItem->getPrice())->withAllData()->build();
     }
     if ($this->entity->getProduct() !== null) {
         $this->entityDTO->shippingWeight = $this->entity->getShippingWeight();
         $this->entityDTO->quantityShippingWeight = $this->entity->getQuantityShippingWeight();
         $this->entityDTO->product = $this->dtoBuilderFactory->getProductDTOBuilder($this->entity->getProduct())->withTags()->build();
     }
 }
Ejemplo n.º 2
0
 public function testCreateDefaults()
 {
     $order = $this->dummyData->getOrder();
     $orderItem = new OrderItem($order);
     $this->assertTrue($orderItem->getId() instanceof UuidInterface);
     $this->assertTrue($orderItem->getCreated() instanceof DateTime);
     $this->assertSame(null, $orderItem->getQuantity());
     $this->assertSame(null, $orderItem->getSku());
     $this->assertSame(null, $orderItem->getName());
     $this->assertSame(null, $orderItem->getDiscountNames());
     $this->assertSame(null, $orderItem->getPrice());
     $this->assertSame(null, $orderItem->getProduct());
     $this->assertSame($order, $orderItem->getOrder());
     $this->assertSame(0, count($orderItem->getOrderItemOptionProducts()));
     $this->assertSame(0, count($orderItem->getOrderItemOptionValues()));
     $this->assertSame(0, count($orderItem->getOrderItemTextOptionValues()));
     $this->assertSame(0, count($orderItem->getCatalogPromotions()));
     $this->assertSame(0, count($orderItem->getProductQuantityDiscounts()));
     $this->assertSame(0, count($orderItem->getAttachments()));
 }