Exemplo n.º 1
0
 public function testCanCrypticCall()
 {
     $mockedSendResult = new Client\Session\Handler\SendResult();
     $mockedSendResult->responseXml = 'dummycrypticresponse';
     $mockedSendResult->responseObject = new \stdClass();
     $mockedSendResult->responseObject->dummyprop = 'dummycrypticresponse';
     $messageResult = new Client\Result($mockedSendResult);
     $expectedMessageResult = new Client\Struct\Command\Cryptic('DAC BRU');
     $mockSessionHandler = $this->getMockBuilder('Amadeus\\Client\\Session\\Handler\\HandlerInterface')->getMock();
     $mockSessionHandler->expects($this->once())->method('sendMessage')->with('Command_Cryptic', $expectedMessageResult, ['endSession' => false])->will($this->returnValue($mockedSendResult));
     $mockSessionHandler->expects($this->never())->method('getLastResponse');
     $mockSessionHandler->expects($this->once())->method('getMessagesAndVersions')->will($this->returnValue(['Command_Cryptic' => "5.1"]));
     $mockResponseHandler = $this->getMockBuilder('Amadeus\\Client\\ResponseHandler\\ResponseHandlerInterface')->getMock();
     $mockResponseHandler->expects($this->once())->method('analyzeResponse')->with($mockedSendResult, 'Command_Cryptic')->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->commandCryptic(new Client\RequestOptions\CommandCrypticOptions(['entry' => 'DAC BRU']));
     $this->assertEquals($messageResult, $response);
 }