public function testCanBeCreatedFromLocation()
 {
     $location = Location::fromCoordinates(Latitude::fromFloat(10.0), Longitude::fromFloat(10.0));
     $jsonLocation = JsonLocation::fromLocation($location);
     $this->assertInstanceOf(JsonLocation::class, $jsonLocation);
     return $jsonLocation;
 }
Example #2
0
 public function testHandlesGetRequestToLocateContainer()
 {
     $request = $this->getMockBuilder(HttpRequest::class)->disableOriginalConstructor()->getMock();
     $requestUrl = $this->getMockBuilder(HttpRequestUrl::class)->disableOriginalConstructor()->getMock();
     $requestUrl->method('getFirstComponent')->willReturn('containers');
     $requestUrl->method('getSecondComponent')->willReturn('the-tracking-number');
     $request->method('isGet')->willReturn(true);
     $request->method('getUrl')->willReturn($requestUrl);
     $trackingNumber = ContainerTrackingNumber::fromString('the-tracking-number');
     $location = Location::fromCoordinates(Latitude::fromFloat(10.0), Longitude::fromFloat(20.0));
     $this->reader->expects($this->once())->method('locateContainer')->with($trackingNumber)->willReturn($location);
     $this->assertEquals('{"latitude":10,"longitude":20}', $this->api->handle($request));
 }
 public function locateContainer(ContainerTrackingNumber $containerTrackingNumber)
 {
     return Location::fromCoordinates(Latitude::fromFloat(10.0), Longitude::fromFloat(10.0));
 }
 /**
  * @expectedException Exception
  * @dataProvider invalidCoordinates
  */
 public function testCannotBeCreatedFromInvalidArguments($latitude)
 {
     Latitude::fromFloat($latitude);
 }
 public function testCanBeCreatedFromCoordinates()
 {
     $location = Location::fromCoordinates(Latitude::fromFloat(0.0), Longitude::fromFloat(0.0));
     $this->assertInstanceOf(Location::class, $location);
 }