diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 885fe3d3945..70717843640 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,6 +25,7 @@ jobs: - "8.0" - "8.1" - "8.2" + - "8.3" php_invoker: [true, false] coverage: [false] experimental: [false] @@ -39,21 +40,32 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP ${{ matrix.php }} uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - ini-values: display_errors=off, log_errors=on + # setup-php defaults to production ini which excludes E_DEPRECATED, + # override to catch deprecation warnings in tests + ini-values: error_reporting=E_ALL, display_errors=on, log_errors=on extensions: xdebug, ctype, dom, json, pcre, reflection, spl - # Since "The PEAR repository has been removed from Composer 2.0" it makes "composer install" to fail on this repo - # revert to composer v1 (and run it outside the checkouted repo, because composer v2 is basically stuck on that error on any command) - tools: composer:v1 + tools: composer env: # https://github.com/shivammathur/setup-php/issues/407#issuecomment-773675741 fail-fast: true + # PEAR_RunTest is needed for .phpt tests. The composer v2 packagist version + # of pear/pear requires PHP 5.4+, and the PHP 5.3-compatible version that was + # previously installable via composer v1 is no longer available since packagist + # dropped composer v1 support. Install via pear CLI provided by setup-php instead. + # + # pear install without sudo fails on PHP 5.6+ with "php_dir is not writeable" + # because setup-php creates root-owned PEAR directories for those versions. + # pear channel-update is needed to avoid "channel has updated its protocols" warning. + - name: Install PEAR + run: sudo pear channel-update pear.php.net && sudo pear install --force PEAR + - name: Install dependencies env: INSTALL_PHP_INVOKER: "${{ matrix.php_invoker == true }}" diff --git a/PHPUnit/Extensions/PhptTestCase.php b/PHPUnit/Extensions/PhptTestCase.php index bb66bdc23eb..ccbe8821228 100644 --- a/PHPUnit/Extensions/PhptTestCase.php +++ b/PHPUnit/Extensions/PhptTestCase.php @@ -44,9 +44,7 @@ */ if (stream_resolve_include_path('PEAR/RunTest.php')) { - $currentErrorReporting = error_reporting(E_ERROR | E_WARNING | E_PARSE); require_once 'PEAR/RunTest.php'; - error_reporting($currentErrorReporting); } /** @@ -122,7 +120,8 @@ public function count() public function run(PHPUnit_Framework_TestResult $result = NULL, array $options = array()) { if (!class_exists('PEAR_RunTest', FALSE)) { - throw new PHPUnit_Framework_Exception('Class PEAR_RunTest not found.'); + $result->addFailure($this, new PHPUnit_Framework_SkippedTestError('PEAR_RunTest not available'), 0); + return $result; } if (isset($GLOBALS['_PEAR_destructor_object_list']) && diff --git a/PHPUnit/Util/GlobalState.php b/PHPUnit/Util/GlobalState.php index 08457fd89ed..008e691e98c 100644 --- a/PHPUnit/Util/GlobalState.php +++ b/PHPUnit/Util/GlobalState.php @@ -107,6 +107,10 @@ public static function backupGlobals(array $blacklist) } } + // skip PEAR globals to avoid "Creation of dynamic property" deprecation + // on PHP 8.2+ when unserializing PEAR_Registry objects + $blacklist[] = '_PEAR_Config_instance'; + foreach (array_keys($GLOBALS) as $key) { if ($key != 'GLOBALS' && !in_array($key, $superGlobalArrays) && @@ -133,6 +137,9 @@ public static function restoreGlobals(array $blacklist) } } + // skip PEAR globals (see comment in backupGlobals) + $blacklist[] = '_PEAR_Config_instance'; + foreach (array_keys($GLOBALS) as $key) { if ($key != 'GLOBALS' && !in_array($key, $superGlobalArrays) && @@ -343,7 +350,8 @@ public static function restoreStaticAttributes() foreach ($staticAttributes as $name => $value) { $reflector = new ReflectionProperty($className, $name); $reflector->setAccessible(TRUE); - $reflector->setValue(unserialize($value)); + // two-arg form: single-arg setValue() for static properties is deprecated in PHP 8.3 + $reflector->setValue(null, unserialize($value)); } } diff --git a/README.md b/README.md index c7f1c2f8493..07921b2c32f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# PHPUnit 3.7.x php 5.3-8.2 compatible +# PHPUnit 3.7.x php 5.3-8.3 compatible -This version of PHPUnit bases on release 3.7.38 and is adjusted for compatibility with PHP 5.3-8.2. +This version of PHPUnit bases on release 3.7.38 and is adjusted for compatibility with PHP 5.3-8.3. The package was created especially for testing https://github.com/zf1s packages. All credits go to original PHPUnit author and contributors. diff --git a/Tests/Framework/AssertTest.php b/Tests/Framework/AssertTest.php index b57055f4bd1..5517d48fc31 100644 --- a/Tests/Framework/AssertTest.php +++ b/Tests/Framework/AssertTest.php @@ -66,6 +66,7 @@ class Framework_AssertTest extends PHPUnit_Framework_TestCase { protected $filesDirectory; + protected $html; protected function setUp() { diff --git a/composer.json b/composer.json index 0bd52ed7d03..eeba5c0a9f5 100644 --- a/composer.json +++ b/composer.json @@ -25,12 +25,6 @@ "support": { "issues": "https://github.com/zf1s/phpunit/issues" }, - "repositories": [ - { - "type": "pear", - "url": "https://pear.php.net" - } - ], "require": { "php": ">=5.3.3", "phpunit/php-text-template": "^1.2.1", @@ -46,9 +40,7 @@ "ext-reflection": "*", "ext-spl": "*" }, - "require-dev": { - "pear-pear.php.net/pear": "~1.9|~1.10" - }, + "require-dev": {}, "suggest": { "phpunit/php-invoker": "~1.1" },