public function testHandle()
 {
     $shipmentGateway = $this->mockService->getShipmentGateway();
     $dtoBuilderFactoryInterface = $this->getDTOBuilderFactory();
     $request = new GetShipmentRatesRequest(new OrderAddressDTO(), new ParcelDTO());
     $response = new GetShipmentRatesResponse();
     $handler = new GetShipmentRatesHandler($shipmentGateway, $dtoBuilderFactoryInterface);
     $handler->handle(new GetShipmentRatesQuery($request, $response));
     $this->assertTrue($response->getShipmentRateDTOs()[0] instanceof ShipmentRateDTO);
 }
 public function postAddShipmentLabel(Request $httpRequest)
 {
     $orderId = $httpRequest->input('orderId');
     $orderItemQty = $httpRequest->input('orderItemQty');
     $comment = $httpRequest->input('comment');
     $shipment = $httpRequest->input('shipment');
     $weight = $httpRequest->input('shipment.weight');
     $length = $httpRequest->input('shipment.length');
     $width = $httpRequest->input('shipment.width');
     $height = $httpRequest->input('shipment.height');
     $order = $this->getOrderWithAllData($orderId);
     $toAddress = $order->shippingAddress;
     $parcel = new ParcelDTO();
     $parcel->length = $length;
     $parcel->width = $width;
     $parcel->height = $height;
     $parcel->weight = $weight * 16;
     $request = new GetShipmentRatesRequest($toAddress, $parcel);
     $response = new GetShipmentRatesResponse();
     $this->dispatchQuery(new GetShipmentRatesQuery($request, $response));
     $shipmentRates = $response->getShipmentRateDTOs();
     $shipment['shipmentRateExternalId'] = $shipmentRates[0]->externalId;
     return $this->renderTemplate('admin/order/add-shipment-label.twig', ['order' => $order, 'orderItemQty' => $orderItemQty, 'shipment' => $shipment, 'comment' => $comment, 'shipmentRates' => $shipmentRates]);
 }