From 1e93692adf87020e17db1a8bcfab0ce2004e47fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Tue, 10 Nov 2026 12:52:06 +0100 Subject: [PATCH] Run tests on PHP 8.6 and update test environment --- .github/workflows/ci.yml | 12 +++++++----- composer.json | 4 ++-- tests/SecureIntegrationTest.php | 16 ++++++++++++++++ tests/ServerTest.php | 4 ++-- tests/SocketServerTest.php | 4 ++-- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12bdec61..2764b600 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,9 +11,10 @@ jobs: strategy: matrix: os: - - ubuntu-24.04 + - ubuntu-26.04 - windows-2022 php: + - 8.6 - 8.5 - 8.4 - 8.3 @@ -31,13 +32,14 @@ jobs: - 5.3 steps: - uses: actions/checkout@v7 + - run: choco install vcredist2012 -y --no-progress + if: ${{ matrix.php >= 5.5 && matrix.php < 7.0 && matrix.os == 'windows-2022' }} # legacy PHP 5.5/5.6 on Windows needs VC 2012 pre-installed until https://github.com/mlocati/powershell-phpmanager/pull/142 is released - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} coverage: xdebug ini-file: development - - run: composer config secure-http false && composer config repo.packagist composer http://packagist.org && composer config preferred-install source - if: ${{ matrix.php < 5.5 && matrix.os == 'windows-2022' }} # legacy PHP on Windows is allowed to use insecure downloads until it will be removed again + tools: ${{ matrix.php < 5.5 && matrix.os == 'windows-2022' && 'composer:2.2.30' || '' }} # legacy PHP < 5.5 on Windows crashes with Composer 2.2.31+ until https://github.com/composer/composer/issues/13276 is fixed - run: composer install - run: vendor/bin/phpunit --coverage-text if: ${{ matrix.php >= 7.3 }} @@ -52,14 +54,14 @@ jobs: - uses: actions/checkout@v7 - uses: shivammathur/setup-php@v2 with: - php-version: 8.5 + php-version: 8.6 coverage: xdebug - run: composer install - run: vendor/bin/phpunit --coverage-text PHPUnit-hhvm: name: PHPUnit (HHVM) - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 continue-on-error: true steps: - uses: actions/checkout@v7 diff --git a/composer.json b/composer.json index 6ff65067..77984433 100644 --- a/composer.json +++ b/composer.json @@ -29,8 +29,8 @@ "php": ">=5.3.0", "evenement/evenement": "^3.0 || ^2.0 || ^1.0", "react/dns": "^1.13", - "react/event-loop": "^1.2", - "react/promise": "^3.2 || ^2.6 || ^1.2.1", + "react/event-loop": "^1.6", + "react/promise": "^3.3 || ^2.6 || ^1.2.1", "react/stream": "^1.4" }, "require-dev": { diff --git a/tests/SecureIntegrationTest.php b/tests/SecureIntegrationTest.php index f3b09668..0f437695 100644 --- a/tests/SecureIntegrationTest.php +++ b/tests/SecureIntegrationTest.php @@ -3,6 +3,7 @@ namespace React\Tests\Socket; use Evenement\EventEmitterInterface; +use React\EventLoop\Loop; use React\Promise\Deferred; use React\Promise\Promise; use React\Socket\ConnectionInterface; @@ -124,6 +125,14 @@ public function testSendDataWithEndToServerReceivesAllData() $client = \React\Async\await(\React\Promise\Timer\timeout($this->connector->connect($this->address), self::TIMEOUT)); /* @var $client ConnectionInterface */ + // clear OpenSSL errors from closing the client before the server reads, + // as legacy PHP < 7.2 does not (https://bugs.php.net/bug.php?id=78775) + $client->on('close', function () { + Loop::futureTick(function () { + while (openssl_error_string() !== false); + }); + }); + $data = str_repeat('a', 200000); $client->end($data); @@ -186,6 +195,13 @@ public function testConnectToServerWhichSendsDataWithEndReceivesAllData() { $data = str_repeat('b', 100000); $this->server->on('connection', function (ConnectionInterface $peer) use ($data) { + // clear OpenSSL errors from closing the server side before the client reads, + // as legacy PHP < 7.2 does not (https://bugs.php.net/bug.php?id=78775) + $peer->on('close', function () { + Loop::futureTick(function () { + while (openssl_error_string() !== false); + }); + }); $peer->end($data); }); diff --git a/tests/ServerTest.php b/tests/ServerTest.php index 00f583e3..3a14b8cf 100644 --- a/tests/ServerTest.php +++ b/tests/ServerTest.php @@ -105,8 +105,8 @@ public function testConstructorThrowsForExistingUnixPath() $this->fail(); } catch (\RuntimeException $e) { if ($e->getCode() === 0) { - // Zend PHP does not currently report a sane error - $this->assertStringEndsWith('Unknown error', $e->getMessage()); + // PHP 8.6+ reports error message without errno, earlier versions do not report a sane error + $this->assertStringEndsWith(PHP_VERSION_ID >= 80600 ? 'Address already in use' : 'Unknown error', $e->getMessage()); } else { $this->assertEquals(SOCKET_EADDRINUSE, $e->getCode()); $this->assertStringEndsWith('Address already in use (EADDRINUSE)', $e->getMessage()); diff --git a/tests/SocketServerTest.php b/tests/SocketServerTest.php index d24154d5..2c18ea8b 100644 --- a/tests/SocketServerTest.php +++ b/tests/SocketServerTest.php @@ -126,8 +126,8 @@ public function testConstructorThrowsForExistingUnixPath() $this->fail(); } catch (\RuntimeException $e) { if ($e->getCode() === 0) { - // Zend PHP does not currently report a sane error - $this->assertStringEndsWith('Unknown error', $e->getMessage()); + // PHP 8.6+ reports error message without errno, earlier versions do not report a sane error + $this->assertStringEndsWith(PHP_VERSION_ID >= 80600 ? 'Address already in use' : 'Unknown error', $e->getMessage()); } else { $this->assertEquals(SOCKET_EADDRINUSE, $e->getCode()); $this->assertStringEndsWith('Address already in use (EADDRINUSE)', $e->getMessage());