public function testHandle()
 {
     $shipmentRate = $this->dummyData->getShipmentRate();
     $dtoBuilderFactoryInterface = $this->getDTOBuilderFactory();
     $shipmentGateway = $this->mockService->getShipmentGateway();
     $shipmentGateway->shouldReceive('getTrimmedRates')->andReturn([$shipmentRate])->once();
     $request = new GetLowestShipmentRatesByDeliveryMethodRequest(new OrderAddressDTO(), new ParcelDTO());
     $response = new GetLowestShipmentRatesByDeliveryMethodResponse();
     $handler = new GetLowestShipmentRatesByDeliveryMethodHandler($shipmentGateway, $dtoBuilderFactoryInterface);
     $handler->handle(new GetLowestShipmentRatesByDeliveryMethodQuery($request, $response));
     $this->assertTrue($response->getShipmentRateDTOs()[0] instanceof ShipmentRateDTO);
 }
 /**
  * @param Request $parentRequest
  * @param CartDTO $cart
  * @param string $zip5
  * @param bool $isResidential
  * @return ShipmentRateDTO[]
  */
 private function getTrimmedShipmentRates(Request $parentRequest, CartDTO $cart, $zip5, $isResidential)
 {
     $toAddress = new OrderAddressDTO();
     $toAddress->zip5 = $zip5;
     $toAddress->country = 'US';
     $toAddress->isResidential = $isResidential;
     $defaultLength = 9;
     $defaultWidth = 9;
     $defaultHeight = 9;
     $parcel = new ParcelDTO();
     $parcel->length = $defaultLength;
     $parcel->width = $defaultWidth;
     $parcel->height = $defaultHeight;
     $parcel->weight = $cart->shippingWeight;
     $request = new GetLowestShipmentRatesByDeliveryMethodRequest($toAddress, $parcel);
     $response = new GetLowestShipmentRatesByDeliveryMethodResponse();
     $this->dispatchQuery(new GetLowestShipmentRatesByDeliveryMethodQuery($request, $response));
     $shipmentRateDTOs = $response->getShipmentRateDTOs();
     if (empty($shipmentRateDTOs)) {
         $this->flashError('Unable to estimate shipping.');
     }
     return $shipmentRateDTOs;
 }