public function __construct(Cart $cart, DTOBuilderFactoryInterface $dtoBuilderFactory) { $this->entity = $cart; $this->dtoBuilderFactory = $dtoBuilderFactory; $this->entityDTO = new CartDTO(); $this->setId(); $this->setTime(); $this->entityDTO->totalItems = $this->entity->totalItems(); $this->entityDTO->totalQuantity = $this->entity->totalQuantity(); $this->entityDTO->shippingWeight = $this->entity->getShippingWeight(); $this->entityDTO->shippingWeightInPounds = $this->entity->getShippingWeightInPounds(); if ($cart->getShipmentRate() !== null) { $this->entityDTO->shipmentRate = $this->dtoBuilderFactory->getShipmentRateDTOBuilder($cart->getShipmentRate())->build(); } if ($cart->getShippingAddress() !== null) { $this->entityDTO->shippingAddress = $this->dtoBuilderFactory->getOrderAddressDTOBuilder($cart->getShippingAddress())->build(); } if ($cart->getTaxRate() !== null) { $this->entityDTO->taxRate = $this->dtoBuilderFactory->getTaxRateDTOBuilder($cart->getTaxRate())->build(); } if ($cart->getUser() !== null) { $this->entityDTO->user = $this->dtoBuilderFactory->getUserDTOBuilder($cart->getUser())->build(); } }
public function testGetShippingWeight() { $cartItem1 = $this->dummyData->getCartItem(null, 1); $cartItem1->getProduct()->setShippingWeight(16); $cartItem2 = $this->dummyData->getCartItem(null, 3); $cartItem2->getProduct()->setShippingWeight(16); $cart = new Cart(); $cart->addCartItem($cartItem1); $cart->addCartItem($cartItem2); $this->assertSame(64, $cart->getShippingWeight()); }