Skip to content

Commit

Permalink
T-005: Develop Test Functionality for API Status Verification on the …
Browse files Browse the repository at this point in the history
…WSGetTransactionStatus Endpoint
  • Loading branch information
andrei-ghenov committed Mar 4, 2024
1 parent f6c1cfc commit 8188c0f
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/Service/ProductServiceTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace QuickTopUpAPI\Tests\Service;

use PHPUnit\Framework\TestCase;
Expand Down
80 changes: 80 additions & 0 deletions tests/Service/StatusCheckServiceTest.php
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);
}

}

0 comments on commit 8188c0f

Please sign in to comment.