Skip to content

Commit

Permalink
HW-50653: Added tests for ApiClientTest with 204 response status code
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrii Severyn committed Apr 11, 2019
1 parent f0c87a1 commit 0cd2920
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/Hyperwallet/Tests/Util/ApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 0cd2920

Please sign in to comment.