From 0df5a4c81367871f768752001d3f01ed73d4c855 Mon Sep 17 00:00:00 2001 From: Julien Loizelet Date: Fri, 6 Dec 2024 16:34:05 +0900 Subject: [PATCH] test(*): Add php 8.4 in matrix (#134) * test(*): Add php 8.4 in matrix * test(*): Hide deprecated error for Gregwar Captcha if PHP 8.4 --- .github/workflows/coding-standards.yml | 2 +- .github/workflows/php-sdk-development-tests.yml | 2 +- .github/workflows/test-suite.yml | 2 +- docs/USER_GUIDE.md | 2 +- tests/Unit/AbstractBouncerTest.php | 15 +++++++++++++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 1b951dd..4fbf836 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -24,7 +24,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['7.4', '8.0', '8.1', '8.2', '8.3'] + php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] name: Coding standards runs-on: ubuntu-latest diff --git a/.github/workflows/php-sdk-development-tests.yml b/.github/workflows/php-sdk-development-tests.yml index 20ae6a7..039806c 100644 --- a/.github/workflows/php-sdk-development-tests.yml +++ b/.github/workflows/php-sdk-development-tests.yml @@ -71,7 +71,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"] + php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"] name: Test suite runs-on: ubuntu-20.04 diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 7841324..e573fa1 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] name: Test suite runs-on: ubuntu-latest diff --git a/docs/USER_GUIDE.md b/docs/USER_GUIDE.md index c18eff4..7e6178f 100644 --- a/docs/USER_GUIDE.md +++ b/docs/USER_GUIDE.md @@ -46,7 +46,7 @@ Please note that first and foremost a CrowdSec agent must be installed on a serv - `Live mode` or `Stream mode` - AppSec support - Support IpV4 and Ipv6 (Ipv6 range decisions are yet only supported in `Live mode`) -- Large PHP matrix compatibility: 7.2, 7.3, 7.4, 8.0, 8.1, 8.2 and 8.3 +- Large PHP matrix compatibility: from 7.2 to 8.4 - Built-in support for the most known cache systems Redis, Memcached and PhpFiles - Clear, prune and refresh the bouncer cache - Cap remediation level (ex: for sensitives websites: ban will be capped to captcha) diff --git a/tests/Unit/AbstractBouncerTest.php b/tests/Unit/AbstractBouncerTest.php index 62dcf92..0d9aefa 100644 --- a/tests/Unit/AbstractBouncerTest.php +++ b/tests/Unit/AbstractBouncerTest.php @@ -198,6 +198,16 @@ protected function setUp(): void public function testPrivateAndProtectedMethods() { + if (PHP_VERSION_ID >= 80400) { + // Retrieve the current error reporting level + $originalErrorReporting = error_reporting(); + // Suppress deprecated warnings temporarily + // We do this because of + // Deprecated: Gregwar\Captcha\CaptchaBuilder::__construct(): Implicitly marking parameter $builder as nullable + // is deprecated, the explicit nullable type must be used instead + error_reporting($originalErrorReporting & ~E_DEPRECATED); + } + // shouldUseAppSec // Test with TLS $configs = array_merge($this->configs, [ @@ -583,6 +593,11 @@ public function testPrivateAndProtectedMethods() ['not-an-ip'] ); $this->assertEquals(false, $result, 'Should return false if ip is invalid'); + + if (PHP_VERSION_ID >= 80400 && isset($originalErrorReporting)) { + // Restore the original error reporting level + error_reporting($originalErrorReporting); + } } /**