From 0cd29208cf4fa5f3fcce8c743b37effda1b19271 Mon Sep 17 00:00:00 2001 From: Andrii Severyn Date: Thu, 11 Apr 2019 18:47:12 +0300 Subject: [PATCH] HW-50653: Added tests for ApiClientTest with 204 response status code --- .../Hyperwallet/Tests/Util/ApiClientTest.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/Hyperwallet/Tests/Util/ApiClientTest.php b/tests/Hyperwallet/Tests/Util/ApiClientTest.php index c2183bed..d3d3b7e4 100644 --- a/tests/Hyperwallet/Tests/Util/ApiClientTest.php +++ b/tests/Hyperwallet/Tests/Util/ApiClientTest.php @@ -70,6 +70,30 @@ public function testDoPost_with_encryption_successful() { $this->validateRequest('POST', '/test', 'test=true', array('test2' => 'value2'), true, array(), true); } + public function testDoPost_with_encryption_return_response_204_status() { + // Setup data + $clientPath = __DIR__ . "/../../../resources/private-jwkset1"; + $hyperwalletPath = __DIR__ . "/../../../resources/public-jwkset1"; + $originalMessage = array('test2' => 'value2'); + $encryption = new HyperwalletEncryption($clientPath, $hyperwalletPath); + $encryptedMessage = $encryption->encrypt($originalMessage); + + // Execute test + $mockHandler = new MockHandler(array( + new Response(204) + )); + $this->createApiClientWithEncryption($mockHandler); + + $model = new BaseModel(array(), $originalMessage); + + // Execute test + $data = $this->apiClient->doPost('/test', array(), null, array()); + $this->assertEquals(array(), $data); + + // Validate api request + $this->validateRequest('POST', '/test', '', array(), true, array(), true); + } + public function testDoPost_with_encryption_charset_in_content_type() { // Setup data $clientPath = __DIR__ . "/../../../resources/private-jwkset1"; @@ -525,6 +549,23 @@ public function testDoPut_return_response_with_path_placeholder() { $this->validateRequest('PUT', '/test/token', '', array('test2' => 'value2'), true); } + public function testDoPut_return_response_204_status() { + // Setup data + $mockHandler = new MockHandler(array( + new Response(204) + )); + $this->createApiClient($mockHandler); + + $model = new BaseModel(array(), array()); + + // Execute test + $data = $this->apiClient->doPut('/test', array(), $model, array()); + $this->assertEquals(array(), $data); + + // Validate api request + $this->validateRequest('PUT', '/test', '', array(), true); + } + public function testDoPut_throw_exception_connection_issue() { // Setup data $mockHandler = new MockHandler(array(