public function __construct(ShipmentRate $shipmentRate, DTOBuilderFactoryInterface $dtoBuilderFactory)
 {
     $this->entity = $shipmentRate;
     $this->dtoBuilderFactory = $dtoBuilderFactory;
     $this->entityDTO = new ShipmentRateDTO();
     $this->entityDTO->externalId = $this->entity->getExternalId();
     $this->entityDTO->shipmentExternalId = $this->entity->getShipmentExternalId();
     $this->entityDTO->service = $this->entity->getService();
     $this->entityDTO->carrier = $this->entity->getCarrier();
     $this->entityDTO->rate = $this->dtoBuilderFactory->getMoneyDTOBuilder($this->entity->getRate())->build();
     $this->entityDTO->isDeliveryDateGuaranteed = $this->entity->isDeliveryDateGuaranteed();
     $this->entityDTO->deliveryDays = $this->entity->getDeliveryDays();
     $this->entityDTO->estDeliveryDays = $this->entity->getEstDeliveryDays();
     if ($this->entity->getDeliveryMethod()->getId() !== null) {
         $this->entityDTO->deliveryMethod = $this->dtoBuilderFactory->getDeliveryMethodTypeDTOBuilder($this->entity->getDeliveryMethod())->build();
     }
     if ($this->entity->getDeliveryDate() !== null) {
         $this->entityDTO->deliveryDate = $this->entity->getDeliveryDate();
     }
     if ($this->entity->getListRate() !== null) {
         $this->entityDTO->listRate = $this->dtoBuilderFactory->getMoneyDTOBuilder($this->entity->getListRate())->build();
     }
     if ($this->entity->getRetailRate() !== null) {
         $this->entityDTO->retailRate = $this->dtoBuilderFactory->getMoneyDTOBuilder($this->entity->getRetailRate())->build();
     }
 }
Esempio n. 2
0
 public function testCreateDefaults()
 {
     $rate = $this->dummyData->getMoney(907);
     $shipmentRate = new ShipmentRate($rate);
     $this->assertSame(null, $shipmentRate->getExternalId());
     $this->assertSame(null, $shipmentRate->getShipmentExternalId());
     $this->assertSame(null, $shipmentRate->getCarrier());
     $this->assertSame(null, $shipmentRate->getService());
     $this->assertSame($rate, $shipmentRate->getRate());
     $this->assertSame(null, $shipmentRate->getListRate());
     $this->assertSame(null, $shipmentRate->getRetailRate());
     $this->assertSame(null, $shipmentRate->getDeliveryDate());
     $this->assertSame(null, $shipmentRate->getDeliveryDays());
     $this->assertSame(false, $shipmentRate->isDeliveryDateGuaranteed());
     $this->assertSame(null, $shipmentRate->getEstDeliveryDays());
     $this->assertTrue($shipmentRate->getDeliveryMethod()->isStandard());
 }