-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
T-005: Develop Test Functionality for API Status Verification on the …
…WSGetTransactionStatus Endpoint
- Loading branch information
1 parent
f6c1cfc
commit 8188c0f
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
namespace QuickTopUpAPI\Tests\Service; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace QuickTopUpAPI\Tests\Service; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use QuickTopUpAPI\Api\ApiClient; | ||
use QuickTopUpAPI\Service\StatusCheckService; | ||
|
||
/** | ||
* Class StatusCheckServiceTest | ||
* | ||
* @package QuickTopUpAPI\Tests\Service | ||
* | ||
* Test cases for the StatusCheckService class. | ||
*/ | ||
class StatusCheckServiceTest extends TestCase { | ||
|
||
/** | ||
* @var StatusCheckService | ||
* | ||
* The status check service. | ||
*/ | ||
private StatusCheckService $statusCheckService; | ||
|
||
/** | ||
* Test the checkStatus method with a CTID that should return "Pending". | ||
*/ | ||
public function testCheckStatusPending() { | ||
// Testing with a CTID that should return "Pending". | ||
$response = $this->statusCheckService->checkStatus('1234'); | ||
|
||
// Display the response for debugging purposes. | ||
echo "testCheckStatusPending Response: "; | ||
var_dump($response); | ||
|
||
$this->assertArrayHasKey('Status', $response); | ||
$this->assertEquals('Pending', $response['Status']); | ||
} | ||
|
||
/** | ||
* Test the checkStatus method with a CTID that should return "Failed". | ||
*/ | ||
public function testCheckStatusFailed() { | ||
// Testing with a CTID that should return "Failed". | ||
$response = $this->statusCheckService->checkStatus('12345'); | ||
|
||
// Display the response for debugging purposes. | ||
echo "testCheckStatusFailed Response: "; | ||
var_dump($response); | ||
|
||
$this->assertArrayHasKey('Status', $response); | ||
$this->assertEquals('Failed', $response['Status']); | ||
} | ||
|
||
/** | ||
* Test the checkStatus method with a CTID that should return "Successful". | ||
*/ | ||
public function testCheckStatusSuccessful() { | ||
// Using a different CTID that is expected to return "Successful". | ||
// Replace 'anyOtherCTID' with a valid CTID value according to your API's logic. | ||
$response = $this->statusCheckService->checkStatus('anyOtherCTID'); | ||
|
||
echo "testCheckStatusSuccessful Response: "; | ||
var_dump($response); | ||
|
||
$this->assertArrayHasKey('Status', $response); | ||
$this->assertEquals('Successful', $response['Status']); | ||
} | ||
|
||
/** | ||
* Set up the test case. | ||
*/ | ||
protected function setUp(): void { | ||
$apiClient = new ApiClient(); | ||
|
||
// Instantiate StatusCheckService with the real ApiClient. | ||
$this->statusCheckService = new StatusCheckService($apiClient); | ||
} | ||
|
||
} |