diff --git a/src/Amadeus/Client.php b/src/Amadeus/Client.php
index 15540a227..09357ba62 100644
--- a/src/Amadeus/Client.php
+++ b/src/Amadeus/Client.php
@@ -27,6 +27,7 @@
use Amadeus\Client\RequestCreator\RequestCreatorInterface;
use Amadeus\Client\RequestOptions;
use Amadeus\Client\ResponseHandler\ResponseHandlerInterface;
+use Amadeus\Client\Result;
use Amadeus\Client\Session\Handler\HandlerFactory;
use Amadeus\Client\RequestCreator\Factory as RequestCreatorFactory;
use Amadeus\Client\Session\Handler\HandlerInterface;
@@ -205,7 +206,7 @@ public function __construct($params)
*
* Parameters were provided at construction time (sessionhandlerparams)
*
- * @return \stdClass
+ * @return Result
* @throws Exception
*/
public function securityAuthenticate()
@@ -213,7 +214,7 @@ public function securityAuthenticate()
$msgName = 'Security_Authenticate';
$messageOptions = $this->makeMessageOptions([], false, false);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -223,12 +224,17 @@ public function securityAuthenticate()
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
* Terminate a session - only applicable to non-stateless mode.
*
- * @return \stdClass
+ * @return Result
* @throws Exception
*/
public function securitySignOut()
@@ -236,7 +242,7 @@ public function securitySignOut()
$msgName = 'Security_SignOut';
$messageOptions = $this->makeMessageOptions([], false, true);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -244,6 +250,11 @@ public function securitySignOut()
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -258,7 +269,7 @@ public function securitySignOut()
*
* @param RequestOptions\PnrRetrieveOptions $options
* @param array $messageOptions (OPTIONAL) Set ['asString'] = 'false' to get PNR_Reply as a PHP object.
- * @return string|\stdClass|null
+ * @return Result
* @throws Exception
*/
public function pnrRetrieve(RequestOptions\PnrRetrieveOptions $options, $messageOptions = [])
@@ -266,7 +277,7 @@ public function pnrRetrieve(RequestOptions\PnrRetrieveOptions $options, $message
$msgName = 'PNR_Retrieve';
$messageOptions = $this->makeMessageOptions($messageOptions, true);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -274,6 +285,11 @@ public function pnrRetrieve(RequestOptions\PnrRetrieveOptions $options, $message
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -281,14 +297,14 @@ public function pnrRetrieve(RequestOptions\PnrRetrieveOptions $options, $message
*
* @param RequestOptions\PnrCreatePnrOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function pnrCreatePnr(RequestOptions\PnrCreatePnrOptions $options, $messageOptions = [])
{
$msgName = 'PNR_AddMultiElements';
$messageOptions = $this->makeMessageOptions($messageOptions, true);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -296,6 +312,11 @@ public function pnrCreatePnr(RequestOptions\PnrCreatePnrOptions $options, $messa
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -306,14 +327,14 @@ public function pnrCreatePnr(RequestOptions\PnrCreatePnrOptions $options, $messa
* @todo implement message creation - maybe split up in separate Create & Modify PNR?
* @param RequestOptions\PnrAddMultiElementsOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function pnrAddMultiElements(RequestOptions\PnrAddMultiElementsOptions $options, $messageOptions = [])
{
$msgName = 'PNR_AddMultiElements';
$messageOptions = $this->makeMessageOptions($messageOptions, true);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -321,6 +342,11 @@ public function pnrAddMultiElements(RequestOptions\PnrAddMultiElementsOptions $o
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -337,7 +363,7 @@ public function pnrAddMultiElements(RequestOptions\PnrAddMultiElementsOptions $o
*
* @param RequestOptions\PnrRetrieveAndDisplayOptions $options Amadeus Record Locator for PNR
* @param array $messageOptions (OPTIONAL) Set ['asString'] = 'false' to get PNR_RetrieveAndDisplayReply as a PHP object.
- * @return string|\stdClass|null
+ * @return Result
* @throws Exception
**/
public function pnrRetrieveAndDisplay(RequestOptions\PnrRetrieveAndDisplayOptions $options, $messageOptions = [])
@@ -345,7 +371,7 @@ public function pnrRetrieveAndDisplay(RequestOptions\PnrRetrieveAndDisplayOption
$msgName = 'PNR_RetrieveAndDisplay';
$messageOptions = $this->makeMessageOptions($messageOptions, true);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -353,6 +379,11 @@ public function pnrRetrieveAndDisplay(RequestOptions\PnrRetrieveAndDisplayOption
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -360,14 +391,14 @@ public function pnrRetrieveAndDisplay(RequestOptions\PnrRetrieveAndDisplayOption
*
* @param RequestOptions\PnrCancelOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function pnrCancel(RequestOptions\PnrCancelOptions $options, $messageOptions = [])
{
$msgName = 'PNR_Cancel';
$messageOptions = $this->makeMessageOptions($messageOptions, true);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -375,6 +406,11 @@ public function pnrCancel(RequestOptions\PnrCancelOptions $options, $messageOpti
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -384,14 +420,14 @@ public function pnrCancel(RequestOptions\PnrCancelOptions $options, $messageOpti
*
* @param RequestOptions\QueueListOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function queueList(RequestOptions\QueueListOptions $options, $messageOptions = [])
{
$msgName = 'Queue_List';
$messageOptions = $this->makeMessageOptions($messageOptions);
- $wsResult = $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -400,9 +436,10 @@ public function queueList(RequestOptions\QueueListOptions $options, $messageOpti
$messageOptions
);
- $this->responseHandler->analyzeResponse($this->getLastResponse(), $msgName);
-
- return $wsResult;
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -410,14 +447,14 @@ public function queueList(RequestOptions\QueueListOptions $options, $messageOpti
*
* @param RequestOptions\QueuePlacePnrOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function queuePlacePnr(RequestOptions\QueuePlacePnrOptions $options, $messageOptions = [])
{
$msgName = 'Queue_PlacePNR';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -425,6 +462,11 @@ public function queuePlacePnr(RequestOptions\QueuePlacePnrOptions $options, $mes
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -432,14 +474,14 @@ public function queuePlacePnr(RequestOptions\QueuePlacePnrOptions $options, $mes
*
* @param RequestOptions\QueueRemoveItemOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function queueRemoveItem(RequestOptions\QueueRemoveItemOptions $options, $messageOptions = [])
{
$msgName = 'Queue_RemoveItem';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -447,6 +489,11 @@ public function queueRemoveItem(RequestOptions\QueueRemoveItemOptions $options,
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -454,14 +501,14 @@ public function queueRemoveItem(RequestOptions\QueueRemoveItemOptions $options,
*
* @param RequestOptions\QueueMoveItemOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function queueMoveItem(RequestOptions\QueueMoveItemOptions $options, $messageOptions = [])
{
$msgName = 'Queue_MoveItem';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -469,6 +516,11 @@ public function queueMoveItem(RequestOptions\QueueMoveItemOptions $options, $mes
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -478,14 +530,14 @@ public function queueMoveItem(RequestOptions\QueueMoveItemOptions $options, $mes
*
* @param RequestOptions\OfferVerifyOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function offerVerify(RequestOptions\OfferVerifyOptions $options, $messageOptions = [])
{
$msgName = 'Offer_VerifyOffer';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -493,6 +545,11 @@ public function offerVerify(RequestOptions\OfferVerifyOptions $options, $message
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -500,14 +557,14 @@ public function offerVerify(RequestOptions\OfferVerifyOptions $options, $message
*
* @param RequestOptions\OfferConfirmAirOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function offerConfirmAir(RequestOptions\OfferConfirmAirOptions $options, $messageOptions = [])
{
$msgName = 'Offer_ConfirmAirOffer';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -515,6 +572,11 @@ public function offerConfirmAir(RequestOptions\OfferConfirmAirOptions $options,
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -522,14 +584,14 @@ public function offerConfirmAir(RequestOptions\OfferConfirmAirOptions $options,
*
* @param RequestOptions\OfferConfirmHotelOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function offerConfirmHotel(RequestOptions\OfferConfirmHotelOptions $options, $messageOptions = [])
{
$msgName = 'Offer_ConfirmHotelOffer';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -537,6 +599,11 @@ public function offerConfirmHotel(RequestOptions\OfferConfirmHotelOptions $optio
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -544,14 +611,14 @@ public function offerConfirmHotel(RequestOptions\OfferConfirmHotelOptions $optio
*
* @param RequestOptions\OfferConfirmCarOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function offerConfirmCar(RequestOptions\OfferConfirmCarOptions $options, $messageOptions = [])
{
$msgName = 'Offer_ConfirmCarOffer';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -559,6 +626,11 @@ public function offerConfirmCar(RequestOptions\OfferConfirmCarOptions $options,
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -566,14 +638,14 @@ public function offerConfirmCar(RequestOptions\OfferConfirmCarOptions $options,
*
* @param RequestOptions\FareMasterPricerTbSearch $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function fareMasterPricerTravelBoardSearch(RequestOptions\FareMasterPricerTbSearch $options, $messageOptions = [])
{
$msgName = 'Fare_MasterPricerTravelBoardSearch';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -581,6 +653,11 @@ public function fareMasterPricerTravelBoardSearch(RequestOptions\FareMasterPrice
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -588,14 +665,14 @@ public function fareMasterPricerTravelBoardSearch(RequestOptions\FareMasterPrice
*
* @param RequestOptions\FarePricePnrWithBookingClassOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function farePricePnrWithBookingClass(RequestOptions\FarePricePnrWithBookingClassOptions $options, $messageOptions = [])
{
$msgName = 'Fare_PricePNRWithBookingClass';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -603,6 +680,11 @@ public function farePricePnrWithBookingClass(RequestOptions\FarePricePnrWithBook
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -610,14 +692,14 @@ public function farePricePnrWithBookingClass(RequestOptions\FarePricePnrWithBook
*
* @param RequestOptions\FareCheckRulesOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function fareCheckRules(RequestOptions\FareCheckRulesOptions $options, $messageOptions = [])
{
$msgName = 'Fare_CheckRules';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -625,6 +707,11 @@ public function fareCheckRules(RequestOptions\FareCheckRulesOptions $options, $m
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -632,14 +719,14 @@ public function fareCheckRules(RequestOptions\FareCheckRulesOptions $options, $m
*
* @param RequestOptions\FareConvertCurrencyOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function fareConvertCurrency(RequestOptions\FareConvertCurrencyOptions $options, $messageOptions = [])
{
$msgName = 'Fare_ConvertCurrency';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -647,6 +734,11 @@ public function fareConvertCurrency(RequestOptions\FareConvertCurrencyOptions $o
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -654,14 +746,14 @@ public function fareConvertCurrency(RequestOptions\FareConvertCurrencyOptions $o
*
* @param RequestOptions\AirSellFromRecommendationOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function airSellFromRecommendation(RequestOptions\AirSellFromRecommendationOptions $options, $messageOptions = [])
{
$msgName = 'Air_SellFromRecommendation';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -669,6 +761,11 @@ public function airSellFromRecommendation(RequestOptions\AirSellFromRecommendati
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -676,14 +773,14 @@ public function airSellFromRecommendation(RequestOptions\AirSellFromRecommendati
*
* @param RequestOptions\AirFlightInfoOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function airFlightInfo(RequestOptions\AirFlightInfoOptions $options, $messageOptions = [])
{
$msgName = 'Air_FlightInfo';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -691,6 +788,11 @@ public function airFlightInfo(RequestOptions\AirFlightInfoOptions $options, $mes
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -698,14 +800,14 @@ public function airFlightInfo(RequestOptions\AirFlightInfoOptions $options, $mes
*
* @param RequestOptions\CommandCrypticOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function commandCryptic(RequestOptions\CommandCrypticOptions $options, $messageOptions = [])
{
$msgName = 'Command_Cryptic';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -713,6 +815,11 @@ public function commandCryptic(RequestOptions\CommandCrypticOptions $options, $m
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -720,14 +827,14 @@ public function commandCryptic(RequestOptions\CommandCrypticOptions $options, $m
*
* @param RequestOptions\MiniRuleGetFromPricingRecOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function miniRuleGetFromPricingRec(RequestOptions\MiniRuleGetFromPricingRecOptions $options, $messageOptions = [])
{
$msgName = 'MiniRule_GetFromPricingRec';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -735,6 +842,11 @@ public function miniRuleGetFromPricingRec(RequestOptions\MiniRuleGetFromPricingR
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -742,14 +854,14 @@ public function miniRuleGetFromPricingRec(RequestOptions\MiniRuleGetFromPricingR
*
* @param RequestOptions\InfoEncodeDecodeCityOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function infoEncodeDecodeCity(RequestOptions\InfoEncodeDecodeCityOptions $options, $messageOptions = [])
{
$msgName = 'Info_EncodeDecodeCity';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -757,6 +869,11 @@ public function infoEncodeDecodeCity(RequestOptions\InfoEncodeDecodeCityOptions
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
@@ -765,14 +882,14 @@ public function infoEncodeDecodeCity(RequestOptions\InfoEncodeDecodeCityOptions
*
* @param RequestOptions\TicketCreateTstFromPricingOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function ticketCreateTSTFromPricing(RequestOptions\TicketCreateTstFromPricingOptions $options, $messageOptions = [])
{
$msgName = 'Ticket_CreateTSTFromPricing';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -780,6 +897,11 @@ public function ticketCreateTSTFromPricing(RequestOptions\TicketCreateTstFromPri
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
@@ -787,14 +909,14 @@ public function ticketCreateTSTFromPricing(RequestOptions\TicketCreateTstFromPri
*
* @param RequestOptions\PriceXplorerExtremeSearchOptions $options
* @param array $messageOptions
- * @return mixed
+ * @return Result
*/
public function priceXplorerExtremeSearch(RequestOptions\PriceXplorerExtremeSearchOptions $options, $messageOptions = [])
{
$msgName = 'PriceXplorer_ExtremeSearch';
$messageOptions = $this->makeMessageOptions($messageOptions);
- return $this->sessionHandler->sendMessage(
+ $sendResult = $this->sessionHandler->sendMessage(
$msgName,
$this->requestCreator->createRequest(
$msgName,
@@ -802,6 +924,11 @@ public function priceXplorerExtremeSearch(RequestOptions\PriceXplorerExtremeSear
),
$messageOptions
);
+
+ return $this->responseHandler->analyzeResponse(
+ $sendResult,
+ $msgName
+ );
}
/**
diff --git a/src/Amadeus/Client/ResponseHandler/Base.php b/src/Amadeus/Client/ResponseHandler/Base.php
index 2be271bf5..2a8f60867 100644
--- a/src/Amadeus/Client/ResponseHandler/Base.php
+++ b/src/Amadeus/Client/ResponseHandler/Base.php
@@ -23,7 +23,8 @@
namespace Amadeus\Client\ResponseHandler;
use Amadeus\Client\Exception;
-use Amadeus\Client\Util\MsgBodyExtractor;
+use Amadeus\Client\Result;
+use Amadeus\Client\Session\Handler\SendResult;
/**
* Base Response Handler
@@ -43,55 +44,110 @@ class Base implements ResponseHandlerInterface
/**
* Analyze the response from the server and throw an exception when an error has been detected.
*
- * @param string $response The last response received by the client
+ * @param SendResult $sendResult The Send Result from the Session Handler
* @param string $messageName The message that was called
*
* @throws Exception
* @throws \RuntimeException
- * @return bool
+ * @return Result
*/
- public function analyzeResponse($response, $messageName)
+ public function analyzeResponse($sendResult, $messageName)
{
$methodName = 'analyze' . str_replace('_', '', ucfirst($messageName)).'Response';
if (method_exists($this, $methodName)) {
return $this->$methodName(
- MsgBodyExtractor::extract($response)
+ $sendResult
);
} else {
- throw new \RuntimeException('Response checker for ' . $messageName . ' is not implemented');
+ return new Result($sendResult, Result::STATUS_UNKNOWN);
}
}
/**
- * @param string $response PNR_AddMultiElements XML string
- * @return bool
- * @throws Exception
+ * @param SendResult $response PNR_AddMultiElements result
+ * @return Result
*/
protected function analyzePnrAddMultiElementsResponse($response)
{
+ $analyzeResponse = new Result($response);
+
+ $domXpath = $this->makeDomXpath($response->responseXml);
+
+ //General Errors:
+ $queryAllErrorCodes = "//m:generalErrorInfo//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode";
+ $queryAllErrorMsg = "//m:generalErrorInfo/m:errorWarningDescription/m:freeText";
+
+ $errorCodeNodeList = $domXpath->query($queryAllErrorCodes);
+
+ if ($errorCodeNodeList->length > 0) {
+ $analyzeResponse->status = Result::STATUS_ERROR;
+
+ $code = $errorCodeNodeList->item(0)->nodeValue;
+ $errorTextNodeList = $domXpath->query($queryAllErrorMsg);
+ $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);
+
+ $analyzeResponse->errors[] = new Result\NotOk($code, $message, 'general');
+ }
+
+ //Segment errors:
+ $querySegmentErrorCodes = "//m:originDestinationDetails//m:errorInfo/m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode";
+ $querySegmentErrorMsg = "//m:originDestinationDetails//m:errorInfo/m:errorWarningDescription/m:freeText";
+
+ $errorCodeNodeList = $domXpath->query($querySegmentErrorCodes);
+
+ if ($errorCodeNodeList->length > 0) {
+ $analyzeResponse->status = Result::STATUS_ERROR;
+
+ $code = $errorCodeNodeList->item(0)->nodeValue;
+ $errorTextNodeList = $domXpath->query($querySegmentErrorMsg);
+ $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);
+
+ $analyzeResponse->errors[] = new Result\NotOk($code, $message, 'segment');
+ }
+
+ //Element errors:
+ $queryElementErrorCodes = "//m:dataElementsIndiv/m:elementErrorInformation/m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode";
+ $queryElementErrorMsg = "//m:dataElementsIndiv//m:elementErrorInformation/m:errorWarningDescription/m:freeText";
+
+ $errorCodeNodeList = $domXpath->query($queryElementErrorCodes);
+
+ if ($errorCodeNodeList->length > 0) {
+ $analyzeResponse->status = Result::STATUS_ERROR;
+ $code = $errorCodeNodeList->item(0)->nodeValue;
+
+ $errorTextNodeList = $domXpath->query($queryElementErrorMsg);
+ $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);
+
+ $analyzeResponse->errors[] = new Result\NotOk($code, $message, 'element');
+ }
+
+
+ return $analyzeResponse;
}
/**
- * @param string $response Queue_List XML string
- * @return bool
+ * @param SendResult $response Queue_List result
+ * @return Result
* @throws Exception
*/
protected function analyzeQueueListResponse($response)
{
- $analysisResponse = true;
+ $analysisResponse = new Result($response);
$domDoc = new \DOMDocument('1.0', 'UTF-8');
- $domDoc->loadXML($response);
+ $domDoc->loadXML($response->responseXml);
$errorCodeNode = $domDoc->getElementsByTagName("errorCode")->item(0);
if (!is_null($errorCodeNode)) {
+ $analysisResponse->status = Result::STATUS_WARN;
+
$errorCode = $errorCodeNode->nodeValue;
$errorMessage = $this->getErrorTextFromQueueErrorCode($errorCode);
- throw new Exception($errorMessage, $errorCode);
+ $analysisResponse->warnings[] = new Result\NotOk($errorCode, $errorMessage);
}
return $analysisResponse;
@@ -128,7 +184,7 @@ protected function getErrorTextFromQueueErrorCode($errorCode)
$errorMessage = (array_key_exists($errorCode, $recognizedErrors)) ? $recognizedErrors[$errorCode] : '';
if ($errorMessage === '') {
- $errorMessage = " QUEUE ERROR '" . $errorCode . "' (Error message unavailable)";
+ $errorMessage = "QUEUE ERROR '" . $errorCode . "' (Error message unavailable)";
}
return $errorMessage;
@@ -136,18 +192,46 @@ protected function getErrorTextFromQueueErrorCode($errorCode)
/**
+ * Make a Xpath-queryable object for an XML string
+ *
* @param string $response
* @return \DOMXPath
+ * @throws Exception when there's a problem loading the message
*/
protected function makeDomXpath($response)
{
$domDoc = new \DOMDocument('1.0', 'UTF-8');
- $domDoc->loadXML($response);
- $uri = $domDoc->documentElement->lookupNamespaceUri(null);
+ $domXpath = null;
+ $loadResult = $domDoc->loadXML($response);
+
+ if ($loadResult === true) {
+ $uri = $domDoc->documentElement->lookupNamespaceUri(null);
- $domXpath = new \DOMXPath($domDoc);
- $domXpath->registerNamespace(self::XMLNS_PREFIX, $uri);
+ $domXpath = new \DOMXPath($domDoc);
+ $domXpath->registerNamespace(self::XMLNS_PREFIX, $uri);
+ } else {
+ throw new Exception('Could not load response message into DOMDocument');
+ }
return $domXpath;
}
+
+ /**
+ * Convert a DomNodeList of nodes containing a (potentially partial) error message into a string.
+ *
+ * @param \DOMNodeList $errorTextNodeList
+ * @return string|null
+ */
+ protected function makeMessageFromMessagesNodeList($errorTextNodeList)
+ {
+ return implode(
+ ' - ',
+ array_map(
+ function($item) {
+ return $item->nodeValue;
+ },
+ iterator_to_array($errorTextNodeList)
+ )
+ );
+ }
}
diff --git a/src/Amadeus/Client/ResponseHandler/ResponseHandlerInterface.php b/src/Amadeus/Client/ResponseHandler/ResponseHandlerInterface.php
index a955161e5..103fdffc6 100644
--- a/src/Amadeus/Client/ResponseHandler/ResponseHandlerInterface.php
+++ b/src/Amadeus/Client/ResponseHandler/ResponseHandlerInterface.php
@@ -23,6 +23,8 @@
namespace Amadeus\Client\ResponseHandler;
use Amadeus\Client\Exception;
+use Amadeus\Client\Result;
+use Amadeus\Client\Session\Handler\SendResult;
/**
* ResponseHandlerInterface
@@ -35,12 +37,12 @@ interface ResponseHandlerInterface
/**
* Analyze the response from the server and throw an exception when an error has been detected.
*
- * @param string $response The last response received by the client
+ * @param SendResult $sendResult The Send Result from the Session Handler
* @param string $messageName The message that was called
*
* @throws Exception When an error is detected
* @throws \RuntimeException When there is a problem calling the response handler
- * @return mixed Will return true if no problems occurred.
+ * @return Result
*/
- public function analyzeResponse($response, $messageName);
+ public function analyzeResponse($sendResult, $messageName);
}
diff --git a/src/Amadeus/Client/Result.php b/src/Amadeus/Client/Result.php
new file mode 100644
index 000000000..636adb33f
--- /dev/null
+++ b/src/Amadeus/Client/Result.php
@@ -0,0 +1,102 @@
+
+ */
+class Result
+{
+ /**
+ * Status indicator for a success situation
+ */
+ const STATUS_OK = 'OK';
+ /**
+ * Status indicator for a warning situation.
+ */
+ const STATUS_WARN = 'WARN';
+ /**
+ * Status indicator for an error response.
+ */
+ const STATUS_ERROR = 'ERR';
+ /**
+ * Status indicator for a response which could not be checked for warnings/errors.
+ */
+ const STATUS_UNKNOWN = 'UNKNOWN';
+
+ /**
+ * Status of the result
+ *
+ * see self::STATUS_*
+ *
+ * @var string
+ */
+ public $status;
+
+ /**
+ * Array of warnings found
+ *
+ * @var NotOk[]
+ */
+ public $warnings = [];
+
+ /**
+ * Array of errors found
+ *
+ * @var NotOk[]
+ */
+ public $errors = [];
+
+ /**
+ * The actual result received after performing the web service call.
+ *
+ * @var \stdClass
+ */
+ public $response;
+
+ /**
+ * The raw contents of the Soap Envelope received after performing the web service call.
+ *
+ * @var string
+ */
+ public $responseXml;
+
+ /**
+ * Result constructor.
+ *
+ * @param SendResult $sendResult
+ * @param string $status
+ */
+ public function __construct($sendResult, $status = self::STATUS_OK)
+ {
+ $this->response = $sendResult->responseObject;
+ $this->responseXml = $sendResult->responseXml;
+ $this->status = $status;
+ }
+}
diff --git a/src/Amadeus/Client/Result/NotOk.php b/src/Amadeus/Client/Result/NotOk.php
new file mode 100644
index 000000000..45ab90585
--- /dev/null
+++ b/src/Amadeus/Client/Result/NotOk.php
@@ -0,0 +1,61 @@
+
+ */
+class NotOk
+{
+ /**
+ * @var mixed
+ */
+ public $code;
+
+ /**
+ * @var string
+ */
+ public $text;
+
+ /**
+ * @var string
+ */
+ public $level;
+
+ /**
+ * NotOk constructor.
+ *
+ * @param string|int|null $code
+ * @param string|null $text
+ * @param string|null $level
+ */
+ public function __construct($code = null, $text = null, $level = null)
+ {
+ $this->code = $code;
+ $this->text = $text;
+ $this->level = $level;
+ }
+}
diff --git a/src/Amadeus/Client/Session/Handler/Base.php b/src/Amadeus/Client/Session/Handler/Base.php
index 296613cc6..4b5a37680 100644
--- a/src/Amadeus/Client/Session/Handler/Base.php
+++ b/src/Amadeus/Client/Session/Handler/Base.php
@@ -190,19 +190,19 @@ public function __construct(SessionHandlerParams $params)
* @param string $messageName Method Operation name as defined in the WSDL.
* @param BaseWsMessage $messageBody
* @param array $messageOptions options: bool 'asString', bool 'endSession'
- * @return mixed
+ * @return SendResult
* @throws \InvalidArgumentException
* @throws Client\Exception
* @throws \SoapFault
*/
public function sendMessage($messageName, Client\Struct\BaseWsMessage $messageBody, $messageOptions = [])
{
- $result = null;
+ $result = new SendResult();
$this->prepareForNextMessage($messageName, $messageOptions);
try {
- $result = $this->getSoapClient()->$messageName($messageBody);
+ $result->responseObject = $this->getSoapClient()->$messageName($messageBody);
$this->logRequestAndResponse($messageName);
@@ -230,9 +230,7 @@ public function sendMessage($messageName, Client\Struct\BaseWsMessage $messageBo
throw new Client\Exception($ex->getMessage(), $ex->getCode(), $ex);
}
- if ($messageOptions['asString'] === true) {
- $result = Client\Util\MsgBodyExtractor::extract($this->getLastResponse());
- }
+ $result->responseXml = Client\Util\MsgBodyExtractor::extract($this->getLastResponse());
return $result;
}
diff --git a/src/Amadeus/Client/Session/Handler/HandlerInterface.php b/src/Amadeus/Client/Session/Handler/HandlerInterface.php
index 113aecfde..e7c173038 100644
--- a/src/Amadeus/Client/Session/Handler/HandlerInterface.php
+++ b/src/Amadeus/Client/Session/Handler/HandlerInterface.php
@@ -46,7 +46,7 @@ public function __construct(SessionHandlerParams $params);
* @param string $messageName The Method name to be called (from the WSDL)
* @param BaseWsMessage $messageBody The message's body to be sent to the server
* @param array $messageOptions Optional options on how to handle this particular message.
- * @return string|\stdClass
+ * @return SendResult
*/
public function sendMessage($messageName, BaseWsMessage $messageBody, $messageOptions);
diff --git a/src/Amadeus/Client/Session/Handler/SendResult.php b/src/Amadeus/Client/Session/Handler/SendResult.php
new file mode 100644
index 000000000..28be549d0
--- /dev/null
+++ b/src/Amadeus/Client/Session/Handler/SendResult.php
@@ -0,0 +1,41 @@
+
+ */
+class SendResult
+{
+ /**
+ * @var string
+ */
+ public $responseXml;
+ /**
+ * @var \stdClass|array
+ */
+ public $responseObject;
+}
diff --git a/src/Amadeus/Client/Session/Handler/SoapHeader4.php b/src/Amadeus/Client/Session/Handler/SoapHeader4.php
index 88a783c22..56aca6fea 100644
--- a/src/Amadeus/Client/Session/Handler/SoapHeader4.php
+++ b/src/Amadeus/Client/Session/Handler/SoapHeader4.php
@@ -107,6 +107,7 @@ protected function prepareForNextMessage($messageName, $messageOptions)
* @param string $lastResponse
* @param array $messageOptions
* @param mixed $result
+ * @return void
*/
protected function handlePostMessage($messageName, $lastResponse, $messageOptions, $result)
{
diff --git a/tests/Amadeus/Client/ParamsTest.php b/tests/Amadeus/Client/ParamsTest.php
index d6955d6ec..8f93b6d0a 100644
--- a/tests/Amadeus/Client/ParamsTest.php
+++ b/tests/Amadeus/Client/ParamsTest.php
@@ -144,5 +144,35 @@ public function testCanLoadFromArrayParamObjects()
$this->assertInstanceOf('Amadeus\Client\Params\SessionHandlerParams', $params->sessionHandlerParams);
$this->assertInstanceOf('Amadeus\Client\Params\RequestCreatorParams', $params->requestCreatorParams);
}
+
+ public function testCanCreateParamsWithAuthParamsObject()
+ {
+ $authParams = new Params\AuthParams([
+ 'officeId' => 'BRUXXXXXX',
+ 'originatorTypeCode' => 'U',
+ 'userId' => 'WSXXXXXX',
+ 'organizationId' => 'NMC-XXXXXX',
+ 'passwordLength' => '4',
+ 'passwordData' => base64_encode('TEST')
+ ]);
+
+ $theParamArray = [
+ 'authParams' => $authParams,
+ 'sessionHandlerParams' => [
+ 'wsdl' => '/var/fake/file/path',
+ 'stateful' => true,
+ 'logger' => new NullLogger()
+ ],
+ 'requestCreatorParams' => [
+ 'originatorOfficeId' => 'BRUXXXXXX',
+ 'receivedFrom' => 'some RF string'
+ ]
+ ];
+
+ $params = new Params($theParamArray);
+
+ $this->assertEquals($authParams, $params->authParams);
+ $this->assertNull($params->sessionHandlerParams->authParams);
+ }
}
diff --git a/tests/Amadeus/Client/ResponseHandler/BaseTest.php b/tests/Amadeus/Client/ResponseHandler/BaseTest.php
index 252816240..6af60a550 100644
--- a/tests/Amadeus/Client/ResponseHandler/BaseTest.php
+++ b/tests/Amadeus/Client/ResponseHandler/BaseTest.php
@@ -22,6 +22,8 @@
namespace Test\Amadeus\Client\ResponseHandler;
+use Amadeus\Client\Result;
+use Amadeus\Client\Session\Handler\SendResult;
use Test\Amadeus\BaseTestCase;
use Amadeus\Client\ResponseHandler;
@@ -33,35 +35,93 @@
*/
class BaseTest extends BaseTestCase
{
- public function testCanThrowCorrectErrorForEmptyQueue()
+ public function testCanFindTopLevelErrorMessageInPnrReply()
{
- $this->setExpectedException('\Amadeus\Client\Exception', "Queue category empty", 926);
+ $respHandler = new ResponseHandler\Base();
+
+ $sendResult = new SendResult();
+ $sendResult->responseXml = $this->getTestFile('faultyPnrCreateTopError.txt');
+
+ $result = $respHandler->analyzeResponse($sendResult, 'PNR_AddMultiElements');
- $xml = $this->getTestFile('emptyqueueresponse.txt');
+ $this->assertEquals(Result::STATUS_ERROR, $result->status);
+ $this->assertEquals(1, count($result->errors));
+ $this->assertEquals('102', $result->errors[0]->code);
+ $this->assertEquals("CHECK DATE", $result->errors[0]->text);
+ $this->assertEquals('general', $result->errors[0]->level);
+ }
+ public function testCanFindSegmentLevelErrorMessageInPnrReply()
+ {
$respHandler = new ResponseHandler\Base();
- $respHandler->analyzeResponse($xml, 'Queue_List');
+ $sendResult = new SendResult();
+ $sendResult->responseXml = $this->getTestFile('faultyPnrCreateSegmentError.txt');
+
+ $result = $respHandler->analyzeResponse($sendResult, 'PNR_AddMultiElements');
+
+ $this->assertEquals(Result::STATUS_ERROR, $result->status);
+ $this->assertEquals(1, count($result->errors));
+ $this->assertEquals('102', $result->errors[0]->code);
+ $this->assertEquals("CHECK DATE", $result->errors[0]->text);
+ $this->assertEquals('segment', $result->errors[0]->level);
}
- public function testWillThrowGenericErrorForUnknownError()
+ public function testCanFindElementLevelErrorMessageInPnrReply()
{
- $this->setExpectedException('\Amadeus\Client\Exception', " QUEUE ERROR '666' (Error message unavailable)", 666);
+ $respHandler = new ResponseHandler\Base();
+
+ $sendResult = new SendResult();
+ $sendResult->responseXml = $this->getTestFile('faultyPnrCreateElementError.txt');
- $xml = $this->getTestFile('emptyqueueresponsedummy666error.txt');
+ $result = $respHandler->analyzeResponse($sendResult, 'PNR_AddMultiElements');
+
+ $this->assertEquals(Result::STATUS_ERROR, $result->status);
+ $this->assertEquals(1, count($result->errors));
+ $this->assertEquals('4498', $result->errors[0]->code);
+ $this->assertEquals("COMBINATION OF ELEMENTS NOT ALLOWED", $result->errors[0]->text);
+ $this->assertEquals('element', $result->errors[0]->level);
+ }
+ public function testCanSetWarningStatusForEmptyQueue()
+ {
$respHandler = new ResponseHandler\Base();
- $respHandler->analyzeResponse($xml, 'Queue_List');
+ $sendResult = new SendResult();
+ $sendResult->responseXml = $this->getTestFile('emptyqueueresponse.txt');
+
+ $result = $respHandler->analyzeResponse($sendResult, 'Queue_List');
+
+ $this->assertEquals(Result::STATUS_WARN, $result->status);
+ $this->assertEquals(1, count($result->warnings));
+ $this->assertEquals(926, $result->warnings[0]->code);
+ $this->assertEquals("Queue category empty", $result->warnings[0]->text);
}
- public function testWillThrowRuntimeExceptionWhenHandlingResponseFromUnknownMessage()
+ public function testWillSetGenericWarningForUnknownError()
{
- $this->setExpectedException('\RuntimeException', 'is not implemented');
+ $sendResult = new SendResult();
+ $sendResult->responseXml = $this->getTestFile('emptyqueueresponsedummy666error.txt');
$respHandler = new ResponseHandler\Base();
- $respHandler->analyzeResponse('', 'Fare_DisplayFaresForCityPair');
+ $result = $respHandler->analyzeResponse($sendResult, 'Queue_List');
+
+ $this->assertEquals(Result::STATUS_WARN, $result->status);
+ $this->assertEquals(1, count($result->warnings));
+ $this->assertEquals(666, $result->warnings[0]->code);
+ $this->assertEquals("QUEUE ERROR '666' (Error message unavailable)", $result->warnings[0]->text);
}
+ public function testWillReturnUnknownStatusWhenHandlingResponseFromUnknownMessage()
+ {
+ $respHandler = new ResponseHandler\Base();
+
+ $sendResult = new SendResult();
+ $sendResult->responseXml = $this->getTestFile('dummyFareDisplayFaresForCityPairReply.txt');
+
+ $result = $respHandler->analyzeResponse($sendResult, 'Fare_DisplayFaresForCityPair');
+
+ $this->assertEquals(Result::STATUS_UNKNOWN, $result->status);
+ }
}
diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/dummyFareDisplayFaresForCityPairReply.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyFareDisplayFaresForCityPairReply.txt
new file mode 100644
index 000000000..6aaca5e38
--- /dev/null
+++ b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyFareDisplayFaresForCityPairReply.txt
@@ -0,0 +1 @@
+0234V2749Z|2711HEDTAX MAY APPLYHED734SURCHG MAY APPLY-CK RULEAPT736BRULCYAPT736BRULGWAPT736BRULHRAPT736BRUQQPAPT736BRUSTNAPT736ANRLONAPT736ANRLCYAPT736ANRLHRAPT736ANRSTNHED738MORE FARES AVAIL INGBPUSD700EURROE0.6929441.00700706GBP706USD7002437012037EHNSPBRULONB200310A20031001LSNLGBOW72570027014O000O010T000T01073674270274270810202ESNEOWLIGHT72570011O000T00074170274270821603ESNELIGHTRT72570124O010T010741MNR74270274270821604OAAONCEUR7247001770134O000O010T000T01074170274270805SUASOWEU7257001770134O000O010T000T0107941270274251506OBAONCEUR7257001770134O000O010T000T01074170274270874207SSNSGBOW7257001770134O000O010T000T01073674270274270810208LSNLLIGHTRT72570138O010T01074170274270821609NAFNVPROBE7257002070140O000O010T000T01074179412702742776708231177706127863011783270374210EAFEVOWBE7257002370146O000O010T000T01074170274270874211QBAQNCEUR7257002970158O000O010T000T01074170274270874212LSNLOWLIGHT72570029O000T00074170274270821613WUAWOWEU7257002970158O000O010T000T0107941270274251514QAAQNCEUR7247002970158O000O010T000T01074170274270815USNUGBOW7257003170162O000O010T000T010736742702742708102167429FYDISCHOW78972570033O000T0002177429FZDISCHOW78972570033O000T0002187429FJDISCHOW78972570033O000T000219NBDNOWBMI7257003470168O000O010T000T01074179412702742708742207429FYATOW78972570039O000T0002217429FJDISOW78972570039O000T0002227429FZATOW78972570039O000T000223WLHWOWBMI7257003970178O000O010T000T01074179412702742708400247429FYDISOW78972570039O000T0002257429FJATOW78972570039O000T0002267429FZDISOW78972570039O000T000227SSNSLIGHTRT72570188O010T01074170274270821628VUAVOWEU7257004470188O000O010T000T0107941270274251529NBANNCEUR7257004470188O000O010T000T01074170274270874230NAANNCEUR7247004470188O000O010T000T01074170274270831NKLNSTAYBE72570192O010T010741MNR742794174232TAFTVOWBE7257004770194O000O010T000T01074170274270874233TBDTOWBMI7257004970198O000O010T000T0107417941270274270874234WSNWGBOW7257004970198O000O010T000T01073674270274270810235SSNSOWLIGHT72570059O000T00074170274270821636VLHVOWBMI72570061701122O000O010T000T0107417941270274270840037QUAQOWEU72570062701124O000O010T000T0107941270274251538VBAVNCEUR72570062701124O000O010T000T01074170274270874239VAAVNCEUR72470062701124O000O010T000T01074170274270840WBDWOWBMI72570063701126O000O010T000T0107417941270274270874241USNULIGHTRT725701138O010T01074170274270821642EKLESTAYBE725701140O010T010741MNR742794674243VSNVGBOW72570071701142O000O010T000T01073674270274270810244AAFAVOWBE72570077701154O000O010T000T01074170274270874245USNUOWLIGHT72570079O000T00074170274270821646UOKUSKYBE725701161O010T010736742MNR7427941270274270811547VBDVOWBMI72570081701162O000O010T000T0107417941270274270874248NAFNSTAYBE725701167O010T010741MNR742794170274270874249LBALNCEUR72570084701168O000O010T000T01074170274270874250QLHQOWBMI72570084701168O000O010T000T0107417941270274270840051LAALNCEUR72470084701168O000O010T000T01074170274270852HUAHOWEU72570084701168O000O010T000T0107941270274251553WSNWLIGHTRT725701178O010T01074170274270821654TKLTTIMEBE725701179O010T010741794670274274255EAFESTAYBE725701181O010T010741MNR742794670274270874256RBARCLUBNN725701185O010T010741745742SU70274270874257QSNQGBOW72570095701190O000O010T000T01073674270274270810258QKLQSTAYBE725701193O010T010741MNR742794674259QBDQOWBMI725700103701206O000O010T000T0107417941270274270874260WAFWSTAYBE725701213O010T010741MNR742794670274270874261HAFHVOWBE725700107701214O000O010T000T01074170274270874262KSNKOWGB725700107701214O000O010T000T01073674270274270810263HLHHOWBMI725700108701216O000O010T000T0107417941270274270840064IBDIRTBMI725701216O010T0107417941270274270874265WSNWOWLIGHT725700109O000T00074170274270821666VSNVLIGHTRT725701218O010T01074170274270821667XOKXSKYBE725701227O010T010736742MNR7427941270274270811568LKLLTIMEBE725701232O010T010741794670274274269MUAMOWEU725700120701240O000O010T000T0107941270274251570DSNDOWSN3725700120701240O000O010T000T01074170810271MBAMNCEUR725700120701240O000O010T000T01074170274270874272MAAMNCEUR724700120701240O000O010T000T01074170274270873ZLHZ1OWBMI725700121701242O000O010T000T0107417941270274270840074HKLHSTAYBE725701245O010T010741MNR742794674275QSNQLIGHTRT725701248O010T01074170274270821676HBDHOWBMI725700127701254O000O010T000T0107417941270274270874277QAFQSTAYBE725701256O010T010741MNR742794670274270874278VSNVOWLIGHT725700129O000T00074170274270821679MLHMOWBMI725700131701262O000O010T000T01074170274270840080VBTVBTPACFRRA725701267O010T010741745742279417027422181KSNKRTFLEX725701268O010T01070274270821682MBDMOWBMI725700139701278O000O010T000T0107417941270274270874283HSNHOWGB725700143701286O000O010T000T01073674270274270810284MAFMVOWBE725700147701294O000O010T000T01074170274270874285KKLKSTAYBE725701298O010T010741MNR742794674286QSNQOWLIGHT725700149O000T00074170274270821687QLOQLOSEARA725700150O000T00070274270874288HAFHTIMEBE725701300O010T010741794670274270874289HSNHRTFLEX725701308O010T01070274270821690KAAKNCEUR724700156701312O000O010T000T01074170274270891KBAKNCEUR725700156701312O000O010T000T01074170274270874292BUABOWEU725700156701312O000O010T000T0107941270274251593AOKASKYBE725701312O010T010736742MNR7427941270274270811594MAFMSTAYBE725701314O010T010741MNR742794670274270874295BLHBOWBMI725700167701334O000O010T000T0107417941270274270840096KSNKECOFLX725700169O000T00070274270821697MSNMGBOW725700174701348O000O010T000T01073674270274270810298KBDKOWBMI725700175701350O000O010T000T0107417941270274270874299HLOHLOSEARA725700180O000T000702742708742100MKLMTIMEBE725701362O010T0107417946742101DSNDBUSNOW725700183O000T000708102102MSNMFLEXRT725701368O010T010702742708216103UAFUTIMEBE725701368O010T0107417946708742104RAFRVOWBE725700187701374O000O010T000T010741702742708742105HOKHSKYBE725701376O010T010736742MNR74279412702742708115106HSNHECOFLX725700189O000T000702742708216107HAAHNCEUR724700192701384O000O010T000T010741702742708108HBAHNCEUR725700192701384O000O010T000T010741702742708742109YUAYOWEU725700192701384O000O010T000T01079412702742515110KAFKSTAYBE725701386O010T010741MNR7427946708742111GLHGOWBMI725700199701398O000O010T000T01079412708400112BSNBFLEXRT725701398O010T010708216113DLHDOWBMI725700200701400O000O010T000T01079412702742708400114DBAD2FLBA725701408O010T010708742115RAFRTIMEBE725701412O010T0107417946708742116BBDBOWBMI725700206701412O000O010T000T01074179412702742708742117BSNBGBOW725700206701412O000O010T000T010736742702742708102118BKLBTIMEBE725701413O010T0107417946742119BOKBSKYBE725701426O010T010736742MNR74279412702742708115120JBDJOWBMI725700215701430O000O010T000T01079412702742708742121SKLSTIMEBE725701438O010T0107417946742122YSNYRTFLEX725701438O010T010708216123MSNMFLXECO725700219O000T000702742708216124D9FDRT725701450O010T010736742776151278615122125SAFSVOWBE725700227701454O000O010T000T010708742126BAABNCEUR724700228701456O000O010T000T010741702742708127BBABNCEUR725700228701456O000O010T000T010741702742708742128ZUAZOWEU725700228701456O000O010T000T01079412702742515129XKLXRTBE725701458O010T010742130YSNYTIME1OW725700233701466O000O010T000T010708102131C9FCRT725701475O010T010736742776151278615122132SBDSOWBMI725700238701476O000O010T000T01074179412702742708742133DSNDBUSNRT725701478O010T010708102134BSNBFLXECO725700239O000T000708216135YLHYBMI725700245701490O000O010T000T01079412708400136D9FDOW725700248O000T000736742776151278615122137ZKLZRTBE725701508O010T010742138SAFSEU725701508O010T01079412708742139DAADRT724701508O010T010708140YBAY2FLBA725701521O010T010708742141YAAYRT724701521O010T010708142C9FCOW725700262O000T000736742776151278615122143CSNCOWSN1725700264701528O000O010T000T010708102144YBDYBMI725700265701530O000O010T000T01079412708742145YSNYFULLFLX725700269O000T000708216146MOKMFLBE725701553O010T010794127027423708115147CLHC2OWBMI725700287701574O000O010T000T010708400148CSNCBUSNRT725701578O010T010708102149MLOMLOSEARA725700290O000T000702742708742150JSNJOWSN0725700292701584O000O010T000T010708102151DBDDOWBMI725700296701592O000O010T000T01079412702742708742152YAFYVOWBE725700297701594O000O010T000T010708742153CBAC2FLBA725701608O010T010708742154YOKYFL725700319701638O000O010T000T01079412708115155DAFD2EU725701644O010T010708742156CKLCRTBE725701644O010T010742157CBDC2OWBMI725700324701648O000O010T000T01079412708742158COKC725700334701668O000O010T000T01079412708115159JAAJRT724701669O010T010708160JBAJ2FLBA725701669O010T010708742161CSNCBUSNOW725700349O000T000708102162JKLJRTBE725701749O010T010742163DUADOWEU725700449701898O000O010T000T01079412702742515164JOKJ725700450701900O000O010T000T01079412708115165YOKYEU725700450701900O000O010T000T01079412708115166CLHC22RT724701922O010T010708167CAFCRT1725701930O010T010708742168CLHCBMI725700489701978O000O010T000T01079412708400169YBDY1BMI725700492701984O000O010T000T01079412708742170CUACOWEU725700495701990O000O010T000T01079412702742515171CBDCBMI725700495701990O000O010T000T01079412708742172742YYCIF7247011015O010T010173JLHJ77RT7247011015O010T010174742YYYIF7247011015O010T010175CLHC22OW724700512O000T000708176JKLJOWBE725700523O000T000742177JLHJ77OW724700559O000T000178YAAYOW724700594O000T000708179742YYYIF724700609O000T000180742YYCIF724700609O000T000181FUAFOWEU7257006417011282O000O010T000T01079412702742515182JAAJOW724700641O000T000708183JBAJFL1OW724700641O000T000708184CAFCOW1725700650O000T000708742185YBDYRPI057257012385O010T0107417944702742708742186CBDCRPI057257012916O010T0107417944702742708742187YBDYRPC107257014770O010T0107417944702742708742188CBDCRPC107257015832O010T0107417944702742708742
\ No newline at end of file
diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/emptyqueueresponse.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/emptyqueueresponse.txt
index a89cba51a..24f4d3c54 100644
--- a/tests/Amadeus/Client/ResponseHandler/testfiles/emptyqueueresponse.txt
+++ b/tests/Amadeus/Client/ResponseHandler/testfiles/emptyqueueresponse.txt
@@ -1 +1 @@
-http://www.w3.org/2005/08/addressing/anonymoushttps://nodeD1.test.webservices.amadeus.com/1ASIWAKTABEhttp://webservices.amadeus.com/QDQLRQ_11_1_1Aurn:uuid:2b12cf73-dfa9-8484-9d47-79f58ffc89e68A372FEE-3B6F-D655-680F-78470B6EB48901XVZH0ME51325SOXPIPBOJIT1A47YMNSQXR926
\ No newline at end of file
+http://www.w3.org/2005/08/addressing/anonymoushttps://nodeD1.test.webservices.amadeus.com/1ASIWXXXXXXhttp://webservices.amadeus.com/QDQLRQ_11_1_1Aurn:uuid:2b12cf73-dfa9-8484-9d47-79f58ffc89e68A372FEE-3B6F-D655-680F-78470B6EB48901XVZH0ME51325SOXPIPBOJIT1A47YMNSQXR926
\ No newline at end of file
diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/emptyqueueresponsedummy666error.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/emptyqueueresponsedummy666error.txt
index de52dd87b..331e943de 100644
--- a/tests/Amadeus/Client/ResponseHandler/testfiles/emptyqueueresponsedummy666error.txt
+++ b/tests/Amadeus/Client/ResponseHandler/testfiles/emptyqueueresponsedummy666error.txt
@@ -1 +1 @@
-http://www.w3.org/2005/08/addressing/anonymoushttps://nodeD1.test.webservices.amadeus.com/1ASIWAKTABEhttp://webservices.amadeus.com/QDQLRQ_11_1_1Aurn:uuid:2b12cf73-dfa9-8484-9d47-79f58ffc89e68A372FEE-3B6F-D655-680F-78470B6EB48901XVZH0ME51325SOXPIPBOJIT1A47YMNSQXR666
\ No newline at end of file
+http://www.w3.org/2005/08/addressing/anonymoushttps://nodeD1.test.webservices.amadeus.com/1ASIWXXXXXXhttp://webservices.amadeus.com/QDQLRQ_11_1_1Aurn:uuid:2b12cf73-dfa9-8484-9d47-79f58ffc89e68A372FEE-3B6F-D655-680F-78470B6EB48901XVZH0ME51325SOXPIPBOJIT1A47YMNSQXR666
\ No newline at end of file
diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/faultyPnrCreateElementError.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/faultyPnrCreateElementError.txt
new file mode 100644
index 000000000..2d63c95e3
--- /dev/null
+++ b/tests/Amadeus/Client/ResponseHandler/testfiles/faultyPnrCreateElementError.txt
@@ -0,0 +1 @@
+1AYL3727170516RPWSSUBRU1A098000081900BRU1A0980EHDBRU1A09809991WS17051600081900102600081900BRU1A0980T1ABRUBE00081900BRU1A0980T1ABRUBE00081900BRU1A0980T1ABRUBE1020161022PT2NM1DEVLIEGHERE1DIETERADT1ADTUNYYDEVLIEGHEREDIETERST1RU2221016BRU1A321HK3-GENERIC TRAVEL REQUESTOT1AP337+32495438305OT4TK4PAXXL100816BRU1A0980OT2RM5RMTID:123456RMTID:123456OT3RM6RM*ACECRM/PP-ANTJERM*ACECRM/PP-ANTJEERROT17TK3OK4498EC1A31COMBINATION OF ELEMENTS NOT ALLOWED
\ No newline at end of file
diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/faultyPnrCreateSegmentError.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/faultyPnrCreateSegmentError.txt
new file mode 100644
index 000000000..24e8dcfee
--- /dev/null
+++ b/tests/Amadeus/Client/ResponseHandler/testfiles/faultyPnrCreateSegmentError.txt
@@ -0,0 +1,319 @@
+
+
+
+
+
+ 1A
+ YL4BRY
+ 170516
+
+
+
+
+
+
+ RP
+ WSSU
+ BRU1A0980
+ 00081900
+
+
+ BRU1A0980
+
+ EHD
+
+ BRU1A0980
+ 9991WS
+ 170516
+ 00081900
+ 1148
+
+
+
+
+
+ 00081900
+ BRU1A0980
+
+ T
+
+
+
+ 1A
+ BRU
+
+
+
+
+ BE
+
+
+
+
+
+
+ 00081900
+ BRU1A0980
+
+ T
+
+
+
+ 1A
+ BRU
+
+
+
+
+ BE
+
+
+
+
+
+
+ 00081900
+ BRU1A0980
+
+ T
+
+
+
+ 1A
+ BRU
+
+
+
+
+ BE
+
+
+
+
+
+
+ 1
+
+
+
+ 0
+
+
+
+ 2016
+ 10
+ 22
+
+
+
+
+
+
+ PT
+ 2
+
+ NM
+ 1
+
+
+
+
+ DEVLIEGHERE
+ 1
+
+
+ DIETER
+ YTH
+
+
+
+
+
+
+ 1
+ YTH
+
+
+ UN
+ Y
+ Y
+ DEVLIEGHERE
+ DIETER
+
+
+
+
+
+
+
+
+
+ ST
+ 1
+
+ RU
+ 2
+
+
+
+ 221016
+
+
+ BRU
+
+
+ 1A
+
+
+
+
+ 32
+
+
+
+ 1
+ HK
+
+
+
+ 3
+
+ -GENERIC TRAVEL REQUEST
+
+
+
+
+
+ ERR
+
+ ST
+ 2
+
+ RU
+ 3
+
+
+
+ 220316
+
+
+ BRU
+
+
+ 1A
+
+
+
+
+ 32
+
+
+
+ 1
+ HK
+
+
+
+
+
+ 102
+ EC
+ 1A
+
+
+
+
+ 3
+
+ 1
+
+ CHECK DATE
+
+
+
+
+
+
+
+
+
+ OT
+ 1
+
+ AP
+ 3
+
+
+
+ 3
+ 7
+
+ +32495438305
+
+
+
+
+
+ OT
+ 4
+
+ TK
+ 4
+
+
+ PAX
+
+ XL
+ 100816
+
+ BRU1A0980
+
+
+
+
+
+
+ OT
+ 2
+
+ RM
+ 5
+
+
+
+ RM
+ TID:123456
+
+
+
+
+ RM
+ TID:123456
+
+
+
+
+
+
+ OT
+ 3
+
+ RM
+ 6
+
+
+
+ RM
+ *ACECRM/PP-ANTJE
+
+
+
+
+ RM
+ *
+ ACECRM/PP-ANTJE
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/faultyPnrCreateTopError.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/faultyPnrCreateTopError.txt
new file mode 100644
index 000000000..815c662de
--- /dev/null
+++ b/tests/Amadeus/Client/ResponseHandler/testfiles/faultyPnrCreateTopError.txt
@@ -0,0 +1,287 @@
+
+
+
+
+
+ 102
+ EC
+ 1A
+
+
+
+
+ 3
+
+ 1
+
+ CHECK DATE
+
+
+
+
+
+ 1A
+ YL4BRY
+ 170516
+
+
+
+
+
+
+ RP
+ WSSU
+ BRU1A0980
+ 00081900
+
+
+ BRU1A0980
+
+ EHD
+
+ BRU1A0980
+ 9991WS
+ 170516
+ 00081900
+ 1148
+
+
+
+
+
+ 00081900
+ BRU1A0980
+
+ T
+
+
+
+ 1A
+ BRU
+
+
+
+
+ BE
+
+
+
+
+
+
+ 00081900
+ BRU1A0980
+
+ T
+
+
+
+ 1A
+ BRU
+
+
+
+
+ BE
+
+
+
+
+
+
+ 00081900
+ BRU1A0980
+
+ T
+
+
+
+ 1A
+ BRU
+
+
+
+
+ BE
+
+
+
+
+
+
+ 1
+
+
+
+ 0
+
+
+
+ 2016
+ 10
+ 22
+
+
+
+
+
+
+ PT
+ 2
+
+ NM
+ 1
+
+
+
+
+ DEVLIEGHERE
+ 1
+
+
+ DIETER
+ YTH
+
+
+
+
+
+
+ 1
+ YTH
+
+
+ UN
+ Y
+ Y
+ DEVLIEGHERE
+ DIETER
+
+
+
+
+
+
+
+
+
+ ST
+ 1
+
+ RU
+ 2
+
+
+
+ 221016
+
+
+ BRU
+
+
+ 1A
+
+
+
+
+ 32
+
+
+
+ 1
+ HK
+
+
+
+ 3
+
+ -GENERIC TRAVEL REQUEST
+
+
+
+
+
+
+
+
+
+ OT
+ 1
+
+ AP
+ 3
+
+
+
+ 3
+ 7
+
+ +32495438305
+
+
+
+
+
+ OT
+ 4
+
+ TK
+ 4
+
+
+ PAX
+
+ XL
+ 100816
+
+ BRU1A0980
+
+
+
+
+
+
+ OT
+ 2
+
+ RM
+ 5
+
+
+
+ RM
+ TID:123456
+
+
+
+
+ RM
+ TID:123456
+
+
+
+
+
+
+ OT
+ 3
+
+ RM
+ 6
+
+
+
+ RM
+ *ACECRM/PP-ANTJE
+
+
+
+
+ RM
+ *
+ ACECRM/PP-ANTJE
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/Amadeus/Client/ResultTest.php b/tests/Amadeus/Client/ResultTest.php
new file mode 100644
index 000000000..9c00abfb0
--- /dev/null
+++ b/tests/Amadeus/Client/ResultTest.php
@@ -0,0 +1,52 @@
+
+ */
+class ResultTest extends BaseTestCase
+{
+ public function testCanConstruct()
+ {
+ $responseObject = new \stdClass();
+ $responseObject->dummyProp = new \stdClass();
+
+ $dummySendResult = new SendResult();
+ $dummySendResult->responseObject = $responseObject;
+ $dummySendResult->responseXml = 'dummy XML message';
+
+ $result = new Result($dummySendResult);
+
+ $this->assertEquals(Result::STATUS_OK, $result->status);
+ $this->assertEquals('dummy XML message', $result->responseXml);
+ $this->assertEquals($responseObject, $result->response);
+ }
+}
diff --git a/tests/Amadeus/Client/Session/Handler/SoapHeader2Test.php b/tests/Amadeus/Client/Session/Handler/SoapHeader2Test.php
index 856d4f55b..f8ecd0fab 100644
--- a/tests/Amadeus/Client/Session/Handler/SoapHeader2Test.php
+++ b/tests/Amadeus/Client/Session/Handler/SoapHeader2Test.php
@@ -76,10 +76,12 @@ public function testCanTryPrepareNextMessageWhenAuthenticated()
->method('__getLastResponse')
->will($this->returnValue($dummyPnrReply));
+ $dummyPnrResponseObject = new \stdClass();
+
$overrideSoapClient
->expects($this->any())
->method('PNR_Retrieve')
- ->will($this->returnValue(''));
+ ->will($this->returnValue($dummyPnrResponseObject));
$handler = new SoapHeader2($this->makeSessionHandlerParams(
$overrideSoapClient
@@ -99,8 +101,11 @@ public function testCanTryPrepareNextMessageWhenAuthenticated()
]
);
- $this->assertInternalType('string', $messageResponse);
- $this->assertEquals($dummyPnrReplyExtractedMessage, $messageResponse);
+ $expectedResult = new SendResult();
+ $expectedResult->responseXml = $dummyPnrReplyExtractedMessage;
+ $expectedResult->responseObject = new \stdClass();
+
+ $this->assertEquals($expectedResult, $messageResponse);
}
public function testCanSendAuthCallAndStartSession()
@@ -116,9 +121,14 @@ public function testCanSendAuthCallAndStartSession()
$dummyRequest = $this->getTestFile('soapheader2' . DIRECTORY_SEPARATOR . 'dummySecurityAuth.txt');
$dummyReply = $this->getTestFile('soapheader2' . DIRECTORY_SEPARATOR . 'dummySecurityAuthReply.txt');
- $messageResult = new \stdClass();
- $messageResult->processStatus = new \stdClass();
- $messageResult->processStatus->statusCode = 'P';
+ $wsResponse = new \stdClass();
+ $wsResponse->processStatus = new \stdClass();
+ $wsResponse->processStatus->statusCode = 'P';
+
+ $messageResult = new SendResult();
+ $messageResult->responseObject = $wsResponse;
+ $messageResult->responseXml = Client\Util\MsgBodyExtractor::extract($dummyReply);
+
$overrideSoapClient
->expects($this->atLeastOnce())
@@ -133,7 +143,7 @@ public function testCanSendAuthCallAndStartSession()
$overrideSoapClient
->expects($this->any())
->method('Security_Authenticate')
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($wsResponse));
$handlerParams = $this->makeSessionHandlerParams(
$overrideSoapClient
@@ -203,6 +213,24 @@ public function testCanMakeSoapClientOptionsWithOverrides()
$this->assertEquals($expected, $result);
}
+ public function testSetStatelessNotSupported()
+ {
+ $this->setExpectedException('\Amadeus\Client\Session\Handler\UnsupportedOperationException');
+
+ $sessionHandler = new SoapHeader2($this->makeSessionHandlerParams());
+
+ $sessionHandler->setStateful(false);
+ }
+
+ public function testGetStatefullWillReturnTrue()
+ {
+ $sessionHandler = new SoapHeader2($this->makeSessionHandlerParams());
+
+ $isStateful = $sessionHandler->isStateful();
+
+ $this->assertTrue($isStateful);
+ }
+
/**
* @param \SoapClient|null $overrideSoapClient
* @return SessionHandlerParams
diff --git a/tests/Amadeus/Client/Session/Handler/SoapHeader4Test.php b/tests/Amadeus/Client/Session/Handler/SoapHeader4Test.php
index ad4cff9d9..8ed64fa7c 100644
--- a/tests/Amadeus/Client/Session/Handler/SoapHeader4Test.php
+++ b/tests/Amadeus/Client/Session/Handler/SoapHeader4Test.php
@@ -430,7 +430,7 @@ public function testCanSendMessage()
$overrideSoapClient
->expects($this->any())
->method('PNR_Retrieve')
- ->will($this->returnValue(''));
+ ->will($this->returnValue(new \stdClass()));
$sessionHandlerParams = $this->makeSessionHandlerParams($overrideSoapClient);
$sessionHandler = new SoapHeader4($sessionHandlerParams);
@@ -446,8 +446,12 @@ public function testCanSendMessage()
['asString'=>true,'endSession'=>false]
);
- $this->assertInternalType('string', $messageResponse);
- $this->assertEquals($dummyPnrReplyExtractedMessage, $messageResponse);
+ $expectedResult = new Client\Session\Handler\SendResult();
+ $expectedResult->responseXml = $dummyPnrReplyExtractedMessage;
+ $expectedResult->responseObject = new \stdClass();
+
+
+ $this->assertEquals($expectedResult, $messageResponse);
}
public function testCanHandleMessageThrowingSoapFault()
@@ -580,10 +584,14 @@ public function testCanExtractSessionDataAfterCall()
$messageResponse = $sessionHandler->sendMessage(
'PNR_Retrieve',
$pnrRetrieveMessage,
- ['asString'=>true,'endSession'=>false]
+ ['asString' => true, 'endSession' => false]
);
- $this->assertEquals($this->getTestFile('acspnrreply.xml'), $messageResponse);
+ $expectedResult = new Client\Session\Handler\SendResult();
+ $expectedResult->responseXml = $this->getTestFile('acspnrreply.xml');
+ $expectedResult->responseObject = $this->getTestFile('acspnr.xml');
+
+ $this->assertEquals($expectedResult, $messageResponse);
$sessionData = $sessionHandler->getSessionData();
@@ -633,6 +641,74 @@ public function testCanMakeSoapClientOptionsWithOverrides()
$this->assertEquals($expected, $result);
}
+ public function testCanMakeSessionHandlerWithoutLogger()
+ {
+ $overrideSoapClient = $this->getMock(
+ 'Amadeus\Client\SoapClient',
+ ['__getLastRequest', '__getLastResponse', 'PNR_Retrieve'],
+ [],
+ '',
+ false
+ );
+
+ $dummyPnrRequest = $this->getTestFile('dummyPnrRequest.txt');
+ $dummyPnrReply = $this->getTestFile('sessionheadertestresponse.txt');
+ $dummyPnrReplyExtractedMessage = $this->getTestFile('dummyPnrReplyExtractedMessage.txt');
+
+ $overrideSoapClient
+ ->expects($this->atLeastOnce())
+ ->method('__getLastRequest')
+ ->will($this->returnValue($dummyPnrRequest));
+
+ $overrideSoapClient
+ ->expects($this->atLeastOnce())
+ ->method('__getLastResponse')
+ ->will($this->returnValue($dummyPnrReply));
+
+ $overrideSoapClient
+ ->expects($this->any())
+ ->method('PNR_Retrieve')
+ ->will($this->returnValue(new \stdClass()));
+
+ $sessionHandlerParams = $this->makeSessionHandlerParams($overrideSoapClient);
+ $sessionHandlerParams->logger = null;
+
+ $sessionHandler = new SoapHeader4($sessionHandlerParams);
+
+ $pnrRetrieveMessage = new Client\Struct\Pnr\Retrieve(
+ Client\Struct\Pnr\Retrieve::RETR_TYPE_BY_RECLOC,
+ 'ABC123'
+ );
+
+ $messageResponse = $sessionHandler->sendMessage(
+ 'PNR_Retrieve',
+ $pnrRetrieveMessage,
+ ['asString'=>true,'endSession'=>false]
+ );
+
+ $expectedResult = new Client\Session\Handler\SendResult();
+ $expectedResult->responseXml = $dummyPnrReplyExtractedMessage;
+ $expectedResult->responseObject = new \stdClass();
+
+ $this->assertEquals($expectedResult, $messageResponse);
+ }
+
+ public function testCanTryAuthenticateWithInvalidSessionData()
+ {
+ $invalidSessionData = [
+ 'noSessionID' => 'ABCA2312KJL',
+ 'wrongSequence' => 3
+ ];
+
+ $sessionHandlerParams = $this->makeSessionHandlerParams();
+
+ $sessionHandler = new SoapHeader4($sessionHandlerParams);
+
+ $isAuthenticated = $sessionHandler->setSessionData($invalidSessionData);
+
+ $this->assertFalse($isAuthenticated);
+ }
+
/**
* @return SessionHandlerParams
*/
diff --git a/tests/Amadeus/Client/Session/Handler/testfiles/sessionheadertestresponse.txt b/tests/Amadeus/Client/Session/Handler/testfiles/sessionheadertestresponse.txt
index 06f3c2985..db080ce7a 100644
--- a/tests/Amadeus/Client/Session/Handler/testfiles/sessionheadertestresponse.txt
+++ b/tests/Amadeus/Client/Session/Handler/testfiles/sessionheadertestresponse.txt
@@ -1 +1 @@
-http://www.w3.org/2005/08/addressing/anonymoushttps://nodeD1.test.webservices.amadeus.com/1ASIWAKTABEhttp://webservices.amadeus.com/PNRRET_14_2_1Aurn:uuid:1a0f35bf-c719-5ea4-7146-dbb08d27c250FAEA565D-566D-4AD8-ACDF-3A144007151E01ZURPO74G1KYRVVDZ1MEZ72HY9QE46ZODRD1A25YDLB270116RP1ARCBRU1A098000081900BRU1A0980EHDBRU1A09802003DD2701160008190015193P12--- RLR ---RLR00081900BRU1A0980T1ABRUBE00081900BRU1A0980T1ABRUBEAMSKL0571AKLAMSNL432016628PT1NM1DEVLIEGHERE1DIETER MR1UNYYDEVLIEGHEREDIETER MRST1AIR224061610502406161220BRUOPOSN3811JET1SNDPJF3W1HK319051000MSST2AIR328061608402806161215OPOAMSKL2588YET1KL25YDLB1HK73W023 OPERATED BY TRANSAVIA AIRLINESST3AIR428061613332806161508AMSZYRKL2973YET1KL25YDLB1HKTRN123 OPERATED BY ACCESRAILCNX23OT6AP53P02DIETER.DEVLIEGHERE@BENELUX.AMADEUS.COMOT7TK6OK270116BRU1A0980OT19SSR7OTHS 1ANOSHOW WILL RESULT IN ADM IF UNTKTD/BRUSN 27JANOT21SSR8ADTK 1ATO KL BY 24JUN16/1800Z OTHERWISE WILL BE XXLDOT18OS9328KLPLS VISIT WWW.SNCB-EUROPE.COM/AIRRAILOT20RC10RCRESTRICTED
\ No newline at end of file
+http://www.w3.org/2005/08/addressing/anonymoushttps://nodeD1.test.webservices.amadeus.com/1ASIWXXXXXXhttp://webservices.amadeus.com/PNRRET_14_2_1Aurn:uuid:1a0f35bf-c719-5ea4-7146-dbb08d27c250FAEA565D-566D-4AD8-ACDF-3A144007151E01ZURPO74G1KYRVVDZ1MEZ72HY9QE46ZODRD1A25YDLB270116RP1ARCBRU1A098000081900BRU1A0980EHDBRU1A09802003DD2701160008190015193P12--- RLR ---RLR00081900BRU1A0980T1ABRUBE00081900BRU1A0980T1ABRUBEAMSKL0571AKLAMSNL432016628PT1NM1DEVLIEGHERE1DIETER MR1UNYYDEVLIEGHEREDIETER MRST1AIR224061610502406161220BRUOPOSN3811JET1SNDPJF3W1HK319051000MSST2AIR328061608402806161215OPOAMSKL2588YET1KL25YDLB1HK73W023 OPERATED BY TRANSAVIA AIRLINESST3AIR428061613332806161508AMSZYRKL2973YET1KL25YDLB1HKTRN123 OPERATED BY ACCESRAILCNX23OT6AP53P02DIETER.DEVLIEGHERE@BENELUX.AMADEUS.COMOT7TK6OK270116BRU1A0980OT19SSR7OTHS 1ANOSHOW WILL RESULT IN ADM IF UNTKTD/BRUSN 27JANOT21SSR8ADTK 1ATO KL BY 24JUN16/1800Z OTHERWISE WILL BE XXLDOT18OS9328KLPLS VISIT WWW.SNCB-EUROPE.COM/AIRRAILOT20RC10RCRESTRICTED
\ No newline at end of file
diff --git a/tests/Amadeus/Client/SoapClientTest.php b/tests/Amadeus/Client/SoapClientTest.php
index a1187b58f..62987bfc5 100644
--- a/tests/Amadeus/Client/SoapClientTest.php
+++ b/tests/Amadeus/Client/SoapClientTest.php
@@ -134,7 +134,7 @@ public function testCanParseStuff()
FF93A63C-9002-942A-13D5-90BCA97D3C15
- https://nodeD1.test.webservices.amadeus.com/1ASIWACSBEN
+ https://nodeD1.test.webservices.amadeus.com/1ASIWXXXXXX
http://webservices.amadeus.com/PNRRET_11_3_1A
diff --git a/tests/Amadeus/Client/Util/testfiles/pnrResponseFullEnvelope.txt b/tests/Amadeus/Client/Util/testfiles/pnrResponseFullEnvelope.txt
index 3581f69fb..b332142bc 100644
--- a/tests/Amadeus/Client/Util/testfiles/pnrResponseFullEnvelope.txt
+++ b/tests/Amadeus/Client/Util/testfiles/pnrResponseFullEnvelope.txt
@@ -1 +1 @@
-http://www.w3.org/2005/08/addressing/anonymoushttps://nodeD1.test.webservices.amadeus.com/1ASIWAKTABEhttp://webservices.amadeus.com/PNRRET_14_2_1Aurn:uuid:c71c70f9-b4d5-6fa4-8d43-37ecaa35299a918245EA-0ED7-B82C-F2DB-8D9EAFF7806101XV8U3ATS22RAQ507TIBUC22EZ7MR61A63TY1A26WQ74030216RPWSSUBRU1A098000081900BRU1A0980EHDBRU1A09809991WS03021600081900152300081900BRU1A0980T1ABRUBE00081900BRU1A0980T1ABRUBE00081900BRU1A0980T1ABRUBE1020161022PT2NM1DEVLIEGHERE1DIETERADT1ADTUNYYDEVLIEGHEREDIETERST1RU2221016BRU1A321HK3-GENERIC TRAVEL REQUESTOT1AP337+32495438305OT4TK4PAXOK030216BRU1A0980OT2RM5RMTID:123456RMTID:123456OT3RM6RM*ACECRM/PP-ANTJERM*ACECRM/PP-ANTJE
\ No newline at end of file
+http://www.w3.org/2005/08/addressing/anonymoushttps://nodeD1.test.webservices.amadeus.com/1ASIXXXXXXhttp://webservices.amadeus.com/PNRRET_14_2_1Aurn:uuid:c71c70f9-b4d5-6fa4-8d43-37ecaa35299a918245EA-0ED7-B82C-F2DB-8D9EAFF7806101XV8U3ATS22RAQ507TIBUC22EZ7MR61A63TY1A26WQ74030216RPWSSUBRU1A098000081900BRU1A0980EHDBRU1A09809991WS03021600081900152300081900BRU1A0980T1ABRUBE00081900BRU1A0980T1ABRUBE00081900BRU1A0980T1ABRUBE1020161022PT2NM1DEVLIEGHERE1DIETERADT1ADTUNYYDEVLIEGHEREDIETERST1RU2221016BRU1A321HK3-GENERIC TRAVEL REQUESTOT1AP337+32495438305OT4TK4PAXOK030216BRU1A0980OT2RM5RMTID:123456RMTID:123456OT3RM6RM*ACECRM/PP-ANTJERM*ACECRM/PP-ANTJE
\ No newline at end of file
diff --git a/tests/Amadeus/ClientTest.php b/tests/Amadeus/ClientTest.php
index f6171cef2..2495ef1df 100644
--- a/tests/Amadeus/ClientTest.php
+++ b/tests/Amadeus/ClientTest.php
@@ -141,28 +141,40 @@ public function testWillGetNullFromGetLastReqResWhenNoCallsWerMade()
public function testCanDoDummyPnrRetrieveCall()
{
- $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'A dummy message result'; // Not an actual XML reply.
- $messageResult = 'A dummy message result'; // Not an actual XML reply.
+ $messageResult = new Client\Result($mockedSendResult);
$expectedPnrResult = new Client\Struct\Pnr\Retrieve(Client\Struct\Pnr\Retrieve::RETR_TYPE_BY_RECLOC,'ABC123');
+ $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+
$mockSessionHandler
->expects($this->once())
->method('sendMessage')
->with('PNR_Retrieve', $expectedPnrResult, ['asString' => true, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->once())
->method('getMessagesAndVersions')
->will($this->returnValue(['PNR_Retrieve' => '14.2']));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'PNR_Retrieve')
+ ->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);
@@ -174,28 +186,42 @@ public function testCanDoDummyPnrRetrieveCall()
public function testCanDoDummyPnrRetrieveAndDisplayCall()
{
- $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'A dummy message result'; // Not an actual XML reply.
+ $mockedSendResult->responseObject = new \stdClass();
+ $mockedSendResult->responseObject->dummyprop = 'A dummy property'; // Not an actual response property.
- $messageResult = 'A dummy message result'; // Not an actual XML reply.
+ $messageResult = new Client\Result($mockedSendResult);
$expectedPnrResult = new Client\Struct\Pnr\RetrieveAndDisplay('ABC123');
+ $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+
$mockSessionHandler
->expects($this->once())
->method('sendMessage')
->with('PNR_RetrieveAndDisplay', $expectedPnrResult, ['asString' => true, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->once())
->method('getMessagesAndVersions')
->will($this->returnValue(['PNR_RetrieveAndDisplay' => '14.2']));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'PNR_RetrieveAndDisplay')
+ ->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);
@@ -207,9 +233,12 @@ public function testCanDoDummyPnrRetrieveAndDisplayCall()
public function testCanDoCreatePnrCall()
{
- $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'A dummy message result'; // Not an actual XML reply.
+ $mockedSendResult->responseObject = new \stdClass();
+ $mockedSendResult->responseObject->dummyprop = 'A dummy message result'; // Not an actual response property
- $messageResult = 'A dummy message result'; // Not an actual XML reply.
+ $messageResult = new Client\Result($mockedSendResult);
$options = new Client\RequestOptions\PnrCreatePnrOptions();
$options->actionCode = 11; //11 End transact with retrieve (ER)
@@ -243,59 +272,82 @@ public function testCanDoCreatePnrCall()
);
$expectedPnrResult->dataElementsMaster->dataElementsIndiv[] = $receivedFromElement;
+ $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+
$mockSessionHandler
->expects($this->once())
->method('sendMessage')
->with('PNR_AddMultiElements', $expectedPnrResult, ['asString' => true, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->once())
->method('getMessagesAndVersions')
->will($this->returnValue(['PNR_AddMultiElements' => '14.2']));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'PNR_AddMultiElements')
+ ->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->pnrCreatePnr($options);
$this->assertEquals($messageResult, $response);
-
}
public function testCanDoAddMultiElementsSavePNR()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'A dummy message result'; // Not an actual XML reply.
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseObject = new \stdClass();
+ $mockedSendResult->responseObject->dummyProp = 'A dummy message result'; // Not an actual Soap reply.
+ $mockedSendResult->responseXml = 'A dummy message result'; // Not an actual XML reply
+
+ $messageResult = new Client\Result($mockedSendResult);
$options = new Client\RequestOptions\PnrAddMultiElementsOptions();
$options->actionCode = 11; //11 End transact with retrieve (ER)
-
$expectedPnrResult = new Client\Struct\Pnr\AddMultiElements($options);
$mockSessionHandler
->expects($this->once())
->method('sendMessage')
->with('PNR_AddMultiElements', $expectedPnrResult, ['asString' => true, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->once())
->method('getMessagesAndVersions')
->will($this->returnValue(['PNR_AddMultiElements' => '14.2']));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'PNR_AddMultiElements')
+ ->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);
@@ -308,7 +360,12 @@ public function testCanDoAddMultiElementsSavePNRWithRf()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'A dummy message result'; // Not an actual XML reply.
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseObject = new \stdClass();
+ $mockedSendResult->responseObject->dummyProp = 'A dummy message result'; // Not an actual Soap reply.
+ $mockedSendResult->responseXml = 'A dummy message result'; // Not an actual XML reply
+
+ $messageResult = new Client\Result($mockedSendResult);
$options = new Client\RequestOptions\PnrAddMultiElementsOptions();
$options->actionCode = 11; //11 End transact with retrieve (ER)
@@ -330,19 +387,28 @@ public function testCanDoAddMultiElementsSavePNRWithRf()
->expects($this->once())
->method('sendMessage')
->with('PNR_AddMultiElements', $expectedPnrResult, ['asString' => true, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->once())
->method('getMessagesAndVersions')
->will($this->returnValue(['PNR_AddMultiElements' => '14.2']));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'PNR_AddMultiElements')
+ ->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);
@@ -355,7 +421,12 @@ public function testCanDoDummyPnrCancelCall()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'A dummy message result'; // Not an actual XML reply.
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseObject = new \stdClass();
+ $mockedSendResult->responseObject->dummyProp = 'A dummy message result'; // Not an actual Soap reply.
+ $mockedSendResult->responseXml = 'A dummy message result'; // Not an actual XML reply
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedPnrResult = new Client\Struct\Pnr\Cancel(
new Client\RequestOptions\PnrCancelOptions([
@@ -368,18 +439,27 @@ public function testCanDoDummyPnrCancelCall()
->expects($this->once())
->method('sendMessage')
->with('PNR_Cancel', $expectedPnrResult, ['asString' => true, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->once())
->method('getMessagesAndVersions')
->will($this->returnValue(['PNR_Cancel' => '14.2']));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'PNR_Cancel')
+ ->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);
@@ -401,15 +481,20 @@ public function testCanDoDummyQueueListCall()
$lastResponse = 'http://www.w3.org/2005/08/addressing/anonymoushttps://nodeD1.test.webservices.amadeus.com/ENDPOINThttp://webservices.amadeus.com/QDQLRQ_11_1_1Aurn:uuid:916bb446-a6fc-b8a4-b543-ce4b8ba124e186653CF8-2017-2F7C-AFC2-BD07B22BD185SESSIONID1SECTOKENBRU1A09800C0111- TURBO0023TCZSBRU1A0980WS70020151211701201615711201512111228
';
$messageResult = 'BRU1A09800C0111- TURBO0023TCZSBRU1A0980WS70020151211701201615711201512111228
';
+ $sendResult = new Client\Session\Handler\SendResult();
+ $sendResult->responseXml = $messageResult;
+
+ $expected = new Client\Result($sendResult);
+
$expectedMessageResult = new Client\Struct\Queue\QueueList(50, 0);
$mockSessionHandler
->expects($this->once())
->method('sendMessage')
->with('Queue_List', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($sendResult));
$mockSessionHandler
- ->expects($this->once())
+ ->expects($this->never())
->method('getLastResponse')
->will($this->returnValue($lastResponse));
$mockSessionHandler
@@ -417,12 +502,21 @@ public function testCanDoDummyQueueListCall()
->method('getMessagesAndVersions')
->will($this->returnValue(['Queue_List' => "11.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($sendResult, 'Queue_List')
+ ->will($this->returnValue($expected));
+
$par = new Params();
$par->sessionHandler = $mockSessionHandler;
$par->requestCreatorParams = new Params\RequestCreatorParams([
'receivedFrom' => 'some RF string',
'originatorOfficeId' => 'BRUXXXXXX'
]);
+ $par->responseHandler = $mockResponseHandler;
$client = new Client($par);
@@ -432,14 +526,18 @@ public function testCanDoDummyQueueListCall()
])
);
- $this->assertEquals($messageResult, $response);
+
+ $this->assertEquals($expected, $response);
}
public function testCanDoPlacePNRCall()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dumyplacepnrmessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dumyplacepnrmessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Queue\PlacePnr('ABC123', 'BRUXX0000', new Client\RequestOptions\Queue(['queue'=> 50, 'category' => 0]));
@@ -447,7 +545,7 @@ public function testCanDoPlacePNRCall()
->expects($this->once())
->method('sendMessage')
->with('Queue_PlacePNR', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -456,12 +554,21 @@ public function testCanDoPlacePNRCall()
->method('getMessagesAndVersions')
->will($this->returnValue(['Queue_PlacePNR' => "11.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Queue_PlacePNR')
+ ->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);
@@ -480,7 +587,10 @@ public function testCanDoQueueRemoveItemCall()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dumyremveitemmessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dumyremoveitemmessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Queue\RemoveItem(new Client\RequestOptions\Queue(['queue'=> 50, 'category' => 0]), 'ABC123', 'BRUXX0000');
@@ -488,7 +598,7 @@ public function testCanDoQueueRemoveItemCall()
->expects($this->once())
->method('sendMessage')
->with('Queue_RemoveItem', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -497,12 +607,21 @@ public function testCanDoQueueRemoveItemCall()
->method('getMessagesAndVersions')
->will($this->returnValue(['Queue_RemoveItem' => "11.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Queue_RemoveItem')
+ ->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);
@@ -521,7 +640,10 @@ public function testCanDoQueueMoveItemCall()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dummymoveitemmessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummymoveitemmessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Queue\MoveItem('ABC123', 'BRUXX0000', new Client\RequestOptions\Queue(['queue'=> 50, 'category' => 0]), new Client\RequestOptions\Queue(['queue'=> 60, 'category' => 5]));
@@ -529,7 +651,7 @@ public function testCanDoQueueMoveItemCall()
->expects($this->once())
->method('sendMessage')
->with('Queue_MoveItem', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -538,12 +660,21 @@ public function testCanDoQueueMoveItemCall()
->method('getMessagesAndVersions')
->will($this->returnValue(['Queue_MoveItem' => "11.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Queue_MoveItem')
+ ->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);
@@ -561,17 +692,22 @@ public function testCanDoQueueMoveItemCall()
public function testCanCrypticCall()
{
- $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummycrypticresponse';
+ $mockedSendResult->responseObject = new \stdClass();
+ $mockedSendResult->responseObject->dummyprop = 'dummycrypticresponse';
- $messageResult = '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, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -580,12 +716,21 @@ public function testCanCrypticCall()
->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);
@@ -600,9 +745,12 @@ public function testCanCrypticCall()
public function testCanSendMiniRuleGetFromPricingRec()
{
- $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummyminiruleresponse';
+ $mockedSendResult->responseObject = new \stdClass();
+ $mockedSendResult->responseObject->dummyprop = 'dummyminiruleresponse';
- $messageResult = 'dummycrypticresponse';
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\MiniRule\GetFromPricingRec(
new Client\RequestOptions\MiniRuleGetFromPricingRecOptions([
@@ -616,11 +764,13 @@ public function testCanSendMiniRuleGetFromPricingRec()
)
);
+ $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+
$mockSessionHandler
->expects($this->once())
->method('sendMessage')
->with('MiniRule_GetFromPricingRec', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -629,12 +779,22 @@ public function testCanSendMiniRuleGetFromPricingRec()
->method('getMessagesAndVersions')
->will($this->returnValue(['MiniRule_GetFromPricingRec' => "5.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'MiniRule_GetFromPricingRec')
+ ->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);
@@ -656,7 +816,10 @@ public function testCanDoOfferVerifyCall()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dummyofferverifymessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummyofferverifymessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Offer\Verify(
1,
@@ -667,7 +830,7 @@ public function testCanDoOfferVerifyCall()
->expects($this->once())
->method('sendMessage')
->with('Offer_VerifyOffer', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -676,12 +839,21 @@ public function testCanDoOfferVerifyCall()
->method('getMessagesAndVersions')
->will($this->returnValue(['Offer_VerifyOffer' => "11.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Offer_VerifyOffer')
+ ->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);
@@ -699,7 +871,10 @@ public function testCanDoOfferConfirmHotelOffer()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dummyofferconfirmhotelmessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummyofferconfirmhotelmessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Offer\ConfirmHotel(
new Client\RequestOptions\OfferConfirmHotelOptions([
@@ -710,7 +885,7 @@ public function testCanDoOfferConfirmHotelOffer()
->expects($this->once())
->method('sendMessage')
->with('Offer_ConfirmHotelOffer', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -719,12 +894,21 @@ public function testCanDoOfferConfirmHotelOffer()
->method('getMessagesAndVersions')
->will($this->returnValue(['Offer_ConfirmHotelOffer' => "11.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Offer_ConfirmHotelOffer')
+ ->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);
@@ -740,7 +924,10 @@ public function testCanDoOfferConfirmCarOffer()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dummyofferconfirmcarmessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummyofferconfirmcarmessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Offer\ConfirmCar(
new Client\RequestOptions\OfferConfirmCarOptions([
@@ -751,7 +938,7 @@ public function testCanDoOfferConfirmCarOffer()
->expects($this->once())
->method('sendMessage')
->with('Offer_ConfirmCarOffer', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -760,12 +947,21 @@ public function testCanDoOfferConfirmCarOffer()
->method('getMessagesAndVersions')
->will($this->returnValue(['Offer_ConfirmCarOffer' => "11.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Offer_ConfirmCarOffer')
+ ->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);
@@ -779,20 +975,23 @@ public function testCanDoOfferConfirmCarOffer()
public function testCanDoInfoEncodeDecodeCity()
{
- $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummyinfo-encodedecodecity-message';
- $messageResult = 'dummyinfo-encodedecodecity-message';
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Info\EncodeDecodeCity(
new Client\RequestOptions\InfoEncodeDecodeCityOptions([
])
);
+ $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+
$mockSessionHandler
->expects($this->once())
->method('sendMessage')
->with('Info_EncodeDecodeCity', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -801,12 +1000,21 @@ public function testCanDoInfoEncodeDecodeCity()
->method('getMessagesAndVersions')
->will($this->returnValue(['Info_EncodeDecodeCity' => "05.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Info_EncodeDecodeCity')
+ ->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);
@@ -822,7 +1030,10 @@ public function testCanDoTicketCreateTSTFromPricing()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dummyTicketCreateTSTFromPricingmessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummyTicketCreateTSTFromPricingmessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Ticket\CreateTSTFromPricing(
new Client\RequestOptions\TicketCreateTstFromPricingOptions([
@@ -838,7 +1049,7 @@ public function testCanDoTicketCreateTSTFromPricing()
->expects($this->once())
->method('sendMessage')
->with('Ticket_CreateTSTFromPricing', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -847,12 +1058,21 @@ public function testCanDoTicketCreateTSTFromPricing()
->method('getMessagesAndVersions')
->will($this->returnValue(['Ticket_CreateTSTFromPricing' => "04.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Ticket_CreateTSTFromPricing')
+ ->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);
@@ -873,7 +1093,9 @@ public function testCanDoOfferConfirmAirOffer()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dummyofferconfirmairmessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummyofferconfirmairmessage';
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Offer\ConfirmAir(
new Client\RequestOptions\OfferConfirmAirOptions([
@@ -885,7 +1107,7 @@ public function testCanDoOfferConfirmAirOffer()
->expects($this->once())
->method('sendMessage')
->with('Offer_ConfirmAirOffer', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -894,12 +1116,21 @@ public function testCanDoOfferConfirmAirOffer()
->method('getMessagesAndVersions')
->will($this->returnValue(['Offer_ConfirmAirOffer' => "11.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Offer_ConfirmAirOffer')
+ ->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);
@@ -916,7 +1147,10 @@ public function testCanSendAirSellFromRecommendation()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dummyairsellfromrecommendationrmessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummyairsellfromrecommendationrmessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Air\SellFromRecommendation(
new Client\RequestOptions\AirSellFromRecommendationOptions([
@@ -945,7 +1179,7 @@ public function testCanSendAirSellFromRecommendation()
->expects($this->once())
->method('sendMessage')
->with('Air_SellFromRecommendation', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -954,12 +1188,21 @@ public function testCanSendAirSellFromRecommendation()
->method('getMessagesAndVersions')
->will($this->returnValue(['Air_SellFromRecommendation' => "5.2"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Air_SellFromRecommendation')
+ ->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);
@@ -993,7 +1236,10 @@ public function testCanSendAirFlightInfo()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dummyairflightinformessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummyairflightinformessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Air\FlightInfo(
new Client\RequestOptions\AirFlightInfoOptions([
@@ -1009,7 +1255,7 @@ public function testCanSendAirFlightInfo()
->expects($this->once())
->method('sendMessage')
->with('Air_FlightInfo', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -1018,12 +1264,21 @@ public function testCanSendAirFlightInfo()
->method('getMessagesAndVersions')
->will($this->returnValue(['Air_FlightInfo' => "7.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Air_FlightInfo')
+ ->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);
@@ -1044,7 +1299,10 @@ public function testCanSendFareMasterPricerTravelBoardSearch()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dummyfarepricemasterpricertravelboardsearchresponsemessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummyfarepricemasterpricertravelboardsearchresponsemessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Fare\MasterPricerTravelBoardSearch(
new Client\RequestOptions\FareMasterPricerTbSearch([
@@ -1073,7 +1331,7 @@ public function testCanSendFareMasterPricerTravelBoardSearch()
->expects($this->once())
->method('sendMessage')
->with('Fare_MasterPricerTravelBoardSearch', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -1082,12 +1340,21 @@ public function testCanSendFareMasterPricerTravelBoardSearch()
->method('getMessagesAndVersions')
->will($this->returnValue(['Fare_MasterPricerTravelBoardSearch' => "12.3"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Fare_MasterPricerTravelBoardSearch')
+ ->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);
@@ -1121,7 +1388,10 @@ public function testCanSendPriceXplorerExtremeSearch()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dummyfarepricemasterpricertravelboardsearchresponsemessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummypricexplorerextremesearchresponsemessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\PriceXplorer\ExtremeSearch(
new Client\RequestOptions\PriceXplorerExtremeSearchOptions([
@@ -1138,7 +1408,7 @@ public function testCanSendPriceXplorerExtremeSearch()
->expects($this->once())
->method('sendMessage')
->with('PriceXplorer_ExtremeSearch', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -1147,12 +1417,21 @@ public function testCanSendPriceXplorerExtremeSearch()
->method('getMessagesAndVersions')
->will($this->returnValue(['PriceXplorer_ExtremeSearch' => "10.3"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'PriceXplorer_ExtremeSearch')
+ ->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);
@@ -1174,7 +1453,10 @@ public function testCanFareCheckRules()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dummyfarecheckrulesmessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummyfarecheckrulesmessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Fare\CheckRules(
new Client\RequestOptions\FareCheckRulesOptions([
@@ -1186,7 +1468,7 @@ public function testCanFareCheckRules()
->expects($this->once())
->method('sendMessage')
->with('Fare_CheckRules', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -1195,12 +1477,21 @@ public function testCanFareCheckRules()
->method('getMessagesAndVersions')
->will($this->returnValue(['Fare_CheckRules' => "7.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Fare_CheckRules')
+ ->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);
@@ -1217,7 +1508,10 @@ public function testCanFareConvertCurrency()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dummyfareconvertcurrencymessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummyfareconvertcurrencymessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Fare\ConvertCurrency(
new Client\RequestOptions\FareConvertCurrencyOptions([
@@ -1232,7 +1526,7 @@ public function testCanFareConvertCurrency()
->expects($this->once())
->method('sendMessage')
->with('Fare_ConvertCurrency', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -1241,12 +1535,21 @@ public function testCanFareConvertCurrency()
->method('getMessagesAndVersions')
->will($this->returnValue(['Fare_ConvertCurrency' => "8.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Fare_ConvertCurrency')
+ ->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);
@@ -1266,7 +1569,10 @@ public function testCanFarePricePnrWithBookingClassVersion12()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
- $messageResult = 'dummyfarepricepnrwithbookingclassmessage';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummyfarepricepnrwithbookingclassmessage';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Fare\PricePNRWithBookingClass12(
new Client\RequestOptions\FarePricePnrWithBookingClassOptions([
@@ -1278,7 +1584,7 @@ public function testCanFarePricePnrWithBookingClassVersion12()
->expects($this->once())
->method('sendMessage')
->with('Fare_PricePNRWithBookingClass', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -1287,12 +1593,21 @@ public function testCanFarePricePnrWithBookingClassVersion12()
->method('getMessagesAndVersions')
->will($this->returnValue(['Fare_PricePNRWithBookingClass' => "12.3"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Fare_PricePNRWithBookingClass')
+ ->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);
@@ -1342,19 +1657,23 @@ public function testCanFarePricePnrWithBookingClassVersion14()
public function testCanDoSignOutCall()
{
- $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = '';
+ $mockedSendResult->responseObject = new \stdClass();
+ $mockedSendResult->responseObject->processStatus = new \stdClass();
+ $mockedSendResult->responseObject->processStatus->statusCode = 'P';
- $messageResult = new \stdClass();
- $messageResult->processStatus = new \stdClass();
- $messageResult->processStatus->statusCode = 'P';
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Security\SignOut();
+ $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+
$mockSessionHandler
->expects($this->once())
->method('sendMessage')
->with('Security_SignOut', $expectedMessageResult, ['asString' => false, 'endSession' => true])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -1363,12 +1682,21 @@ public function testCanDoSignOutCall()
->method('getMessagesAndVersions')
->will($this->returnValue(['Security_SignOut' => "4.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Security_SignOut')
+ ->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);
@@ -1379,7 +1707,6 @@ public function testCanDoSignOutCall()
public function testCanDoAuthenticateCall()
{
- $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
$authParams = new Params\AuthParams([
'officeId' => 'BRUXXXXXX',
@@ -1391,9 +1718,13 @@ public function testCanDoAuthenticateCall()
'organizationId' => 'DUMMY-ORG',
]);
- $messageResult = new \stdClass();
- $messageResult->processStatus = new \stdClass();
- $messageResult->processStatus->statusCode = 'P';
+ $mockedSendResult = new Client\Session\Handler\SendResult();
+ $mockedSendResult->responseXml = 'dummy auth response xml';
+ $mockedSendResult->responseObject = new \stdClass();
+ $mockedSendResult->responseObject->processStatus = new \stdClass();
+ $mockedSendResult->responseObject->processStatus->statusCode = 'P';
+
+ $messageResult = new Client\Result($mockedSendResult);
$expectedMessageResult = new Client\Struct\Security\Authenticate(
new Client\RequestOptions\SecurityAuthenticateOptions(
@@ -1401,11 +1732,13 @@ public function testCanDoAuthenticateCall()
)
);
+ $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
+
$mockSessionHandler
->expects($this->once())
->method('sendMessage')
->with('Security_Authenticate', $expectedMessageResult, ['asString' => false, 'endSession' => false])
- ->will($this->returnValue($messageResult));
+ ->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->never())
->method('getLastResponse');
@@ -1414,6 +1747,14 @@ public function testCanDoAuthenticateCall()
->method('getMessagesAndVersions')
->will($this->returnValue(['Security_Authenticate' => "6.1"]));
+ $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();
+
+ $mockResponseHandler
+ ->expects($this->once())
+ ->method('analyzeResponse')
+ ->with($mockedSendResult, 'Security_Authenticate')
+ ->will($this->returnValue($messageResult));
+
$par = new Params();
$par->authParams = $authParams;
$par->sessionHandler = $mockSessionHandler;
@@ -1421,6 +1762,7 @@ public function testCanDoAuthenticateCall()
'receivedFrom' => 'some RF string',
'originatorOfficeId' => 'BRUXXXXXX'
]);
+ $par->responseHandler = $mockResponseHandler;
$client = new Client($par);