Skip to content

Commit

Permalink
Merge pull request #55 from WebFiori/dev
Browse files Browse the repository at this point in the history
feat: Added Support for Testing Service By Class Name
  • Loading branch information
usernane authored Aug 26, 2024
2 parents e1f7253 + d33836e commit 601a2a6
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 601a2a6

Please sign in to comment.