Ejemplo n.º 1
0
 public function __construct(CallContext $callContext)
 {
     $this->url = $callContext->getEndpoint() . $callContext->getPath();
     $this->method = $callContext->getMethod();
     $this->httpClient = $callContext->getHttpClient();
     $this->apiKey = $callContext->getApiKey();
 }
    public function testReferenceException()
    {
        $callContext = new CallContext();
        $callContext->setIdempotenceKey('test');
        $responseHeaders = array('Content-Type' => 'application/json', 'X-GCS-Idempotence-Request-Timestamp' => '12345');
        $responseBody = <<<EOD
{
   "errorId" : "75b0f13a-04a5-41b3-83b8-b295ddb23439-000013c6",
   "errors" : [ {
      "code" : "1400",
      "message" : "DUPLICATE REQUEST IN PROGRESS",
      "httpStatusCode" : 409
   } ]
}
EOD;
        $connectionResponse = new DefaultConnectionResponse(409, $responseHeaders, $responseBody);
        $responseFactory = new ResponseFactory();
        $responseExceptionFactory = new ResponseExceptionFactory();
        $exception = $responseExceptionFactory->createException($connectionResponse->getHttpStatusCode(), $responseFactory->createResponse($connectionResponse, new ResponseClassMap(), $callContext), $callContext);
        $this->assertInstanceOf('\\Ingenico\\Connect\\Sdk\\ReferenceException', $exception);
    }