Example #1
0
 /**
  * Testing the scenario where a user requests no responseXML string in the Result object.
  */
 public function testCanSendAnyMessageRequestNoResponseXml()
 {
     $mockSessionHandler = $this->getMockBuilder('Amadeus\\Client\\Session\\Handler\\HandlerInterface')->getMock();
     $mockedSendResult = new Client\Session\Handler\SendResult();
     $mockedSendResult->responseObject = new \stdClass();
     $mockedSendResult->responseObject->dummy = new \stdClass();
     $mockedSendResult->responseObject->dummy->value = 'this is a dummy value';
     $mockedSendResult->responseXml = 'this is a dummy result which should be removed because we requested no response XML';
     $messageResult = new Client\Result($mockedSendResult);
     $expectedMessageResult = new Client\Struct\DocIssuance\IssueCombined(new Client\RequestOptions\DocIssuanceIssueCombinedOptions(['options' => [new Client\RequestOptions\DocIssuance\Option(['indicator' => Client\RequestOptions\DocIssuance\Option::INDICATOR_DOCUMENT_RECEIPT, 'subCompoundType' => 'EMPRA'])]]));
     $mockSessionHandler->expects($this->once())->method('sendMessage')->with('DocIssuance_IssueCombined', $expectedMessageResult, ['endSession' => false, 'returnXml' => false])->will($this->returnValue($mockedSendResult));
     $mockSessionHandler->expects($this->never())->method('getLastResponse');
     $mockSessionHandler->expects($this->once())->method('getMessagesAndVersions')->will($this->returnValue(['DocIssuance_IssueCombined' => "15.1"]));
     $mockResponseHandler = $this->getMockBuilder('Amadeus\\Client\\ResponseHandler\\ResponseHandlerInterface')->getMock();
     $mockResponseHandler->expects($this->once())->method('analyzeResponse')->with($mockedSendResult, 'DocIssuance_IssueCombined')->will($this->returnValue($messageResult));
     $par = new Params();
     $par->sessionHandler = $mockSessionHandler;
     $par->requestCreatorParams = new Params\RequestCreatorParams(['receivedFrom' => 'some RF string', 'originatorOfficeId' => 'BRUXXXXXX']);
     $par->responseHandler = $mockResponseHandler;
     $expectedMessage = clone $messageResult;
     $expectedMessage->responseXml = null;
     $client = new Client($par);
     $response = $client->docIssuanceIssueCombined(new Client\RequestOptions\DocIssuanceIssueCombinedOptions(['options' => [new Client\RequestOptions\DocIssuance\Option(['indicator' => Client\RequestOptions\DocIssuance\Option::INDICATOR_DOCUMENT_RECEIPT, 'subCompoundType' => 'EMPRA'])]]), ['returnXml' => false]);
     $this->assertEquals($expectedMessage, $response);
 }