/** * @test */ public function it_specifies_new_route_but_do_not_change_the_origin() { $routeSpecification = new RouteSpecification("Hongkong", "Hamburg"); $cargo = new Cargo(new TrackingId(Uuid::uuid4()), $routeSpecification); $anotherRouteSpecification = new RouteSpecification("Dallas", "Rotterdam"); $cargo->specifyNewRoute($anotherRouteSpecification); $this->assertEquals('Dallas', $cargo->routeSpecification()->origin()); $this->assertEquals('Rotterdam', $cargo->routeSpecification()->destination()); $this->assertEquals('Hongkong', $cargo->origin()); }
/** * @param Cargo $aCargo * @return CargoRoutingDto */ public function toDto(Cargo $aCargo) { $cargoRoutingDto = new CargoRoutingDto(); $cargoRoutingDto->setTrackingId($aCargo->trackingId()->toString()); $cargoRoutingDto->setOrigin($aCargo->origin()); $cargoRoutingDto->setFinalDestination($aCargo->routeSpecification()->destination()); foreach ($aCargo->itinerary()->legs() as $leg) { $legDto = new LegDto(); $legDto->setLoadLocation($leg->loadLocation()); $legDto->setUnloadLocation($leg->unloadLocation()); $legDto->setLoadTime($leg->loadTime()->format(\DateTime::ISO8601)); $legDto->setUnloadTime($leg->unloadTime()->format(\DateTime::ISO8601)); $cargoRoutingDto->addLeg($legDto); } return $cargoRoutingDto; }