From a1c5617257466416bf875d312eeb560bf965ecc0 Mon Sep 17 00:00:00 2001 From: Ibrahim Date: Mon, 22 Apr 2024 11:28:55 +0300 Subject: [PATCH 1/3] feat: Added a Method to Get Call Response Code --- webfiori/http/APITestCase.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webfiori/http/APITestCase.php b/webfiori/http/APITestCase.php index 6344aa5..4fb1e9c 100644 --- a/webfiori/http/APITestCase.php +++ b/webfiori/http/APITestCase.php @@ -109,6 +109,14 @@ public function callEndpoint(WebServicesManager $manager, string $requestMethod, public function deletRequest(WebServicesManager $manager, string $endpoint, array $parameters = []) : string { return $this->callEndpoint($manager, RequestMethod::DELETE, $endpoint, $parameters); } + /** + * Returns HTTP response code that will be sent by the call. + * + * @return int An integer that represent HTTP response code. + */ + public function getResponseCode() : int { + return Response::getCode(); + } /** * Sends a GET request to specific endpoint. * From f4ab5a382808e8d95d1eae40b5dbe746f74c416f Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Mon, 26 Aug 2024 17:26:20 +0300 Subject: [PATCH 2/3] fix(test): Added a Check for Value on Testing --- webfiori/http/APITestCase.php | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/webfiori/http/APITestCase.php b/webfiori/http/APITestCase.php index b3fece2..9f1167d 100644 --- a/webfiori/http/APITestCase.php +++ b/webfiori/http/APITestCase.php @@ -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'; @@ -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. * @@ -109,14 +129,6 @@ public function callEndpoint(WebServicesManager $manager, string $requestMethod, public function deletRequest(WebServicesManager $manager, string $endpoint, array $parameters = []) : string { return $this->callEndpoint($manager, RequestMethod::DELETE, $endpoint, $parameters); } - /** - * Returns HTTP response code that will be sent by the call. - * - * @return int An integer that represent HTTP response code. - */ - public function getResponseCode() : int { - return Response::getCode(); - } /** * Sends a GET request to specific endpoint. * From 30bc0ffb78ee19e15f4a372eb3dcb9708719dced Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Mon, 26 Aug 2024 23:04:35 +0300 Subject: [PATCH 3/3] chore: Updated CI Config --- .github/workflows/php70.yml | 6 ++++-- .github/workflows/php71.yml | 6 ++++-- .github/workflows/php72.yml | 6 ++++-- .github/workflows/php73.yml | 6 ++++-- .github/workflows/php74.yml | 6 ++++-- .github/workflows/php80.yml | 6 ++++-- .github/workflows/php81.yml | 6 ++++-- .github/workflows/php82.yml | 6 ++++-- .github/workflows/php83.yml | 6 ++++-- 9 files changed, 36 insertions(+), 18 deletions(-) diff --git a/.github/workflows/php70.yml b/.github/workflows/php70.yml index f74b7a3..11d23dc 100644 --- a/.github/workflows/php70.yml +++ b/.github/workflows/php70.yml @@ -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 @@ -39,4 +39,6 @@ jobs: run: phpunit - name: CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/php71.yml b/.github/workflows/php71.yml index 228ac35..68761fa 100644 --- a/.github/workflows/php71.yml +++ b/.github/workflows/php71.yml @@ -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 @@ -37,4 +37,6 @@ jobs: run: phpunit - name: CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/php72.yml b/.github/workflows/php72.yml index 0b963cc..9677225 100644 --- a/.github/workflows/php72.yml +++ b/.github/workflows/php72.yml @@ -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 @@ -36,6 +36,8 @@ jobs: run: phpunit - name: CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/php73.yml b/.github/workflows/php73.yml index 25b564f..c3928f9 100644 --- a/.github/workflows/php73.yml +++ b/.github/workflows/php73.yml @@ -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 @@ -36,7 +36,9 @@ jobs: run: phpunit - name: CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/php74.yml b/.github/workflows/php74.yml index b512a9a..cfdae1c 100644 --- a/.github/workflows/php74.yml +++ b/.github/workflows/php74.yml @@ -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 @@ -36,7 +36,9 @@ jobs: run: phpunit - name: CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/php80.yml b/.github/workflows/php80.yml index 678d936..8320ca3 100644 --- a/.github/workflows/php80.yml +++ b/.github/workflows/php80.yml @@ -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 @@ -38,4 +38,6 @@ jobs: run: phpunit - name: CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/php81.yml b/.github/workflows/php81.yml index 5a8b65d..282254f 100644 --- a/.github/workflows/php81.yml +++ b/.github/workflows/php81.yml @@ -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 @@ -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 diff --git a/.github/workflows/php82.yml b/.github/workflows/php82.yml index 65d2985..ec4b0e8 100644 --- a/.github/workflows/php82.yml +++ b/.github/workflows/php82.yml @@ -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 @@ -39,4 +39,6 @@ jobs: run: phpunit - name: CodeCov - uses: codecov/codecov-action@v1 \ No newline at end of file + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/php83.yml b/.github/workflows/php83.yml index ec0a5a7..feb86a9 100644 --- a/.github/workflows/php83.yml +++ b/.github/workflows/php83.yml @@ -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 @@ -39,4 +39,6 @@ jobs: run: phpunit - name: CodeCov - uses: codecov/codecov-action@v1 \ No newline at end of file + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file