Skip to content

Commit

Permalink
feat: Added Support for Testing Service By Class Name
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Aug 26, 2024
1 parent 30bc0ff commit d33836e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion webfiori/http/APITestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public function addFile(string $fileIdx, string $filePath, bool $reset = false)
* method such as 'get' or 'post'.
*
* @param string $apiEndpointName The name of the endpoint that will be called such as 'add-user'.
* This also can be the name of the class that implement the service such
* as 'AddUserService::class'.
*
* @param array $parameters A dictionary thar represents the parameters that
* will be sent to the endpoint. The name is parameter name as it appears in
Expand All @@ -72,7 +74,14 @@ public function callEndpoint(WebServicesManager $manager, string $requestMethod,
$manager->setOutputStream(fopen(self::OUTPUT_STREAM,'w'));
$method = strtoupper($requestMethod);
putenv('REQUEST_METHOD='.$method);


if (class_exists($apiEndpointName)) {
$service = new $apiEndpointName();

if ($service instanceof AbstractWebService) {
$apiEndpointName = $service->getName();
}
}
if ($method == 'GET' || $method == 'DELETE') {
foreach ($parameters as $key => $val) {
$_GET[$key] = $this->parseVal($val);
Expand Down

0 comments on commit d33836e

Please sign in to comment.