Example #1
0
 public function testCanDoPointOfRefSearch()
 {
     $mockedSendResult = new Client\Session\Handler\SendResult();
     $mockedSendResult->responseXml = 'dummyinfo-pointofrefsearch-message';
     $messageResult = new Client\Result($mockedSendResult);
     $expectedMessageResult = new Client\Struct\PointOfRef\Search(new Client\RequestOptions\PointOfRefSearchOptions(['targetCategoryCode' => Client\RequestOptions\PointOfRefSearchOptions::TARGET_TRAIN, 'latitude' => '5099155', 'longitude' => '332824', 'searchRadius' => '15000']));
     $mockSessionHandler = $this->getMockBuilder('Amadeus\\Client\\Session\\Handler\\HandlerInterface')->getMock();
     $mockSessionHandler->expects($this->once())->method('sendMessage')->with('PointOfRef_Search', $expectedMessageResult, ['endSession' => false])->will($this->returnValue($mockedSendResult));
     $mockSessionHandler->expects($this->never())->method('getLastResponse');
     $mockSessionHandler->expects($this->once())->method('getMessagesAndVersions')->will($this->returnValue(['PointOfRef_Search' => "02.1"]));
     $mockResponseHandler = $this->getMockBuilder('Amadeus\\Client\\ResponseHandler\\ResponseHandlerInterface')->getMock();
     $mockResponseHandler->expects($this->once())->method('analyzeResponse')->with($mockedSendResult, 'PointOfRef_Search')->will($this->returnValue($messageResult));
     $par = new Params();
     $par->sessionHandler = $mockSessionHandler;
     $par->requestCreatorParams = new Params\RequestCreatorParams(['receivedFrom' => 'some RF string', 'originatorOfficeId' => 'BRUXXXXXX']);
     $par->responseHandler = $mockResponseHandler;
     $client = new Client($par);
     $response = $client->pointOfRefSearch(new Client\RequestOptions\PointOfRefSearchOptions(['targetCategoryCode' => Client\RequestOptions\PointOfRefSearchOptions::TARGET_TRAIN, 'latitude' => '5099155', 'longitude' => '332824', 'searchRadius' => '15000']));
     $this->assertEquals($messageResult, $response);
 }