Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
php_invoker: [true, false]
coverage: [false]
experimental: [false]
Expand All @@ -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 }}"
Expand Down
5 changes: 2 additions & 3 deletions PHPUnit/Extensions/PhptTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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']) &&
Expand Down
10 changes: 9 additions & 1 deletion PHPUnit/Util/GlobalState.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand All @@ -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) &&
Expand Down Expand Up @@ -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));
}
}

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions Tests/Framework/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
class Framework_AssertTest extends PHPUnit_Framework_TestCase
{
protected $filesDirectory;
protected $html;

protected function setUp()
{
Expand Down
10 changes: 1 addition & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down
Loading