Skip to content

Commit

Permalink
Merge pull request #54 from WebFiori/dev
Browse files Browse the repository at this point in the history
fix(test): Added a Check for Value on Testing
  • Loading branch information
usernane authored Aug 26, 2024
2 parents f3e59fc + 30bc0ff commit e1f7253
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 20 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/php70.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Clone Repo
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -39,4 +39,6 @@ jobs:
run: phpunit

- name: CodeCov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
6 changes: 4 additions & 2 deletions .github/workflows/php71.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Clone Repo
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -37,4 +37,6 @@ jobs:
run: phpunit

- name: CodeCov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
6 changes: 4 additions & 2 deletions .github/workflows/php72.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Clone Repo
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -36,6 +36,8 @@ jobs:
run: phpunit

- name: CodeCov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}


6 changes: 4 additions & 2 deletions .github/workflows/php73.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Clone Repo
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -36,7 +36,9 @@ jobs:
run: phpunit

- name: CodeCov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}



6 changes: 4 additions & 2 deletions .github/workflows/php74.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Clone Repo
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -36,7 +36,9 @@ jobs:
run: phpunit

- name: CodeCov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}



6 changes: 4 additions & 2 deletions .github/workflows/php80.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Clone Repo
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -38,4 +38,6 @@ jobs:
run: phpunit

- name: CodeCov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
6 changes: 4 additions & 2 deletions .github/workflows/php81.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Clone Repo
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -37,7 +37,9 @@ jobs:
run: phpunit

- name: CodeCov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: SonarCloud
uses: SonarSource/sonarcloud-github-action@master
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/php82.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Clone Repo
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -39,4 +39,6 @@ jobs:
run: phpunit

- name: CodeCov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
6 changes: 4 additions & 2 deletions .github/workflows/php83.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Clone Repo
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -39,4 +39,6 @@ jobs:
run: phpunit

- name: CodeCov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
24 changes: 22 additions & 2 deletions webfiori/http/APITestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public function callEndpoint(WebServicesManager $manager, string $requestMethod,

if ($method == 'GET' || $method == 'DELETE') {
foreach ($parameters as $key => $val) {
$_GET[$key] = $val;
$_GET[$key] = $this->parseVal($val);
}
$_GET['service'] = $apiEndpointName;
$this->unset($_GET, $parameters, $manager);
} else if ($method == 'POST' || $method == 'PUT') {
foreach ($parameters as $key => $val) {
$_POST[$key] = $val;
$_POST[$key] = $this->parseVal($val);
}
$_POST['service'] = $apiEndpointName;
$_SERVER['CONTENT_TYPE'] = 'multipart/form-data';
Expand All @@ -93,6 +93,26 @@ public function callEndpoint(WebServicesManager $manager, string $requestMethod,

return $retVal;
}
private function parseVal($val) {
$type = gettype($val);

if ($type == 'array') {
$array = [];

foreach ($val as $arrVal) {
if (gettype($val) == 'string') {
$array[] = "'".$arrVal."'";
} else {
$array[] = $arrVal;
}
}

return implode(',', $array);
} else if ($type == 'boolean') {
return $type === true ? 'y' : 'n';
}
return $val;
}
/**
* Sends a DELETE request to specific endpoint.
*
Expand Down

0 comments on commit e1f7253

Please sign in to comment.