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));
 }
Exemple #2
0
<?php

include "Api.php";
include "Parser/Json.php";
include "Parser/Xml.php";
include "Vo/ResponseVO.php";
$api = new Api();
$api->setType(Api::TYPE_XML);
$api->handle();
<?php

namespace bgphp15\nameless;

require __DIR__ . '/src/autoload.php';
header('Content-type: application/json; charset=utf-8');
$api = new Api(new ContainerTrackingReader(), new ContainerTrackingWriter());
$api->handle(HttpRequest::fromSuperglobals());