Skip to content

Commit

Permalink
Merge pull request #260 from blockchyp/feature/javaBug
Browse files Browse the repository at this point in the history
Java test bug and php null exception fix
  • Loading branch information
devops-blockchyp committed Feb 1, 2024
1 parent c0c6d5b commit d79ef43
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/Exception/BlockChypException.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ public static function factory($message, $httpStatus = null, $httpBody = null)
$instance = new static($message);
$instance->setHttpStatus($httpStatus);
$instance->setHttpBody($httpBody);
$instance->setJsonBody(json_decode($httpBody, true));

if (isset($httpBody)) {
$httpBody = json_decode($httpBody, true);
}
$instance->setJsonBody($httpBody);

return $instance;
}

Expand Down
50 changes: 50 additions & 0 deletions tests/itests/MerchantCredentialGenerationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

use BlockChyp\BlockChyp;

require_once(__DIR__ . '/../BlockChypTestCase.php');

class MerchantCredentialGenerationTest extends BlockChypTestCase
{

/**
* @group itest
*/
public function testMerchantCredentialGeneration()
{
$config = $this->loadTestConfiguration();

BlockChyp::setApiKey($config->apiKey);
BlockChyp::setBearerToken($config->bearerToken);
BlockChyp::setSigningKey($config->signingKey);
BlockChyp::setGatewayHost($config->gatewayHost);
BlockChyp::setTestGatewayHost($config->testGatewayHost);
BlockChyp::setDashboardHost($config->dashboardHost);

echo 'Running MerchantCredentialGenerationTest...' . PHP_EOL; // Set request values
$request = [
'test' => true,
'merchantId' => '<MERCHANT ID>',
];

// self::logRequest($request);

try {

$response = BlockChyp::merchantCredentialGeneration($request);

// self::logResponse($response);

// Response assertions

$this->assertTrue($response['success']);

} catch (Exception $ex) {

echo $ex->getTraceAsString();
$this->assertEmpty($ex);

}
$this->processResponseDelay($request);
}
}

0 comments on commit d79ef43

Please sign in to comment.