Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
Add PHPUnit 10 support (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos authored Mar 7, 2023
1 parent 97fc9ca commit 0593935
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": "^5.5 || ^7.0 || ^8.0",
"phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.0 || ^9.0"
"phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.0 || ^9.0 || ^10.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2",
Expand Down
16 changes: 10 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./vendor/autoload.php">
<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation='./vendor/phpunit/phpunit/phpunit.xsd'
bootstrap="./vendor/autoload.php"
cacheResult="false"
>
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Default">
<directory>tests</directory>
Expand Down
6 changes: 5 additions & 1 deletion src/PolyfillTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ trait PolyfillTrait
{
use PolyfillTrait6;
}
} else {
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '10.0.0') < 0) {
trait PolyfillTrait
{
use PolyfillTrait7;
}
} else {
trait PolyfillTrait
{
}
}
23 changes: 9 additions & 14 deletions src/aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@
* with this source code in the file LICENSE.
*/

if (!class_exists('PHPUnit\Framework\Error\Warning')) {
class_alias('PHPUnit_Framework_Error_Warning', 'PHPUnit\Framework\Error\Warning');
}

if (!class_exists('PHPUnit\Framework\ExpectationFailedException')) {
class_alias('PHPUnit_Framework_ExpectationFailedException', 'PHPUnit\Framework\ExpectationFailedException');
}

if (!class_exists('PHPUnit\Framework\TestCase')) {
class_alias('PHPUnit_Framework_TestCase', 'PHPUnit\Framework\TestCase');
}

if (!class_exists('PHPUnit\Runner\Version')) {
class_alias('PHPUnit_Runner_Version', 'PHPUnit\Runner\Version');
foreach ([
'PHPUnit_Framework_Error_Warning' => 'PHPUnit\Framework\Error\Warning',
'PHPUnit_Framework_ExpectationFailedException' => 'PHPUnit\Framework\ExpectationFailedException',
'PHPUnit_Framework_TestCase' => 'PHPUnit\Framework\TestCase',
'PHPUnit_Runner_Version' => 'PHPUnit\Runner\Version',
] as $old => $new) {
if (!class_exists($new) && class_exists($old)) {
class_alias($old, $new);
}
}

0 comments on commit 0593935

Please sign in to comment.