-
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-004: Integrate and Test Product API Endpoints.
- Loading branch information
1 parent
8c033bd
commit caa2078
Showing
4 changed files
with
67 additions
and
4 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
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
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
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,63 @@ | ||
<?php | ||
namespace QuickTopUpAPI\Tests\Service; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use QuickTopUpAPI\Api\ApiClient; | ||
use QuickTopUpAPI\Service\ProductService; | ||
|
||
/** | ||
* Class ProductTest | ||
* | ||
* @package QuickTopUpAPI\Tests\Service | ||
* | ||
* A test case for the ProductService class. | ||
*/ | ||
class ProductServiceTest extends TestCase { | ||
|
||
/** | ||
* @var ProductService | ||
* | ||
* The product service. | ||
*/ | ||
private ProductService $productService; | ||
|
||
/** | ||
* @var string | ||
* | ||
* The API product ID. | ||
*/ | ||
private $apiProductID; | ||
|
||
/** | ||
* Test the getProductById method. | ||
*/ | ||
public function testGetProductById() { | ||
|
||
// Attempt to fetch the product by ID. | ||
$product = $this->productService->getProductById($this->apiProductID); | ||
|
||
// Display the response for debugging purposes. | ||
echo "Response: "; | ||
var_dump($product); | ||
|
||
// You might want to adjust these assertions based on | ||
// the expected product structure. | ||
$this->assertIsArray($product); | ||
$this->assertArrayHasKey('Product', $product); | ||
$this->assertEquals($this->apiProductID , $product['Product']); | ||
} | ||
|
||
/** | ||
* Set up the test case. | ||
*/ | ||
protected function setUp(): void { | ||
$apiClient = new ApiClient(); | ||
|
||
// Instantiate ProductService with the real ApiClient. | ||
$this->productService = new ProductService($apiClient); | ||
|
||
// Set the API product ID. | ||
$this->apiProductID = $_ENV['API_PRODUCT_ID']; | ||
} | ||
|
||
} |