Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #54797 [PhpUnitBridge] Fix
DeprecationErrorHandler
with PhpUnit…
… 10 (HypeMC) This PR was merged into the 5.4 branch. Discussion ---------- [PhpUnitBridge] Fix `DeprecationErrorHandler` with PhpUnit 10 | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT Currently, when using the `DeprecationErrorHandler` with PhpUnit 10, warnings are ignored, e.g.: ```php use PHPUnit\Framework\TestCase; class ExampleTest extends TestCase { public function testFindUniqueTournamentMonths(): void { $someVar = $nonExistentVar; // $nonExistentVar doesn't exist self::assertSame(1, 1); } } ``` ``` PHPUnit 10.5.20 by Sebastian Bergmann and contributors. Runtime: PHP 8.3.4 Configuration: /app/phpunit.xml.dist PHP Warning: Undefined variable $nonExistentVar in /app/tests/ExampleTest.php on line 11 Warning: Undefined variable $nonExistentVar in /app/tests/ExampleTest.php on line 11 . 1 / 1 (100%) Time: 00:00.010, Memory: 19.22 MB OK (1 test, 1 assertion) ``` The reason I added the closure was to return `true`, otherwise, the errors would still be displayed, e.g.: ```diff if ('PHPUnit\Util\ErrorHandler::handleError' === $eh) { return $eh; + } elseif (ErrorHandler::class === $eh) { + return ErrorHandler::instance(); } ``` ``` PHPUnit 10.5.20 by Sebastian Bergmann and contributors. Runtime: PHP 8.3.4 Configuration: /app/phpunit.xml.dist PHP Warning: Undefined variable $nonExistentVar in /app/tests/ExampleTest.php on line 11 Warning: Undefined variable $nonExistentVar in /app/tests/ExampleTest.php on line 11 W 1 / 1 (100%) Time: 00:00.009, Memory: 19.22 MB OK, but there were issues! Tests: 1, Assertions: 1, Warnings: 1. ``` Now, it works as expected: ``` PHPUnit 10.5.20 by Sebastian Bergmann and contributors. Runtime: PHP 8.3.4 Configuration: /app/phpunit.xml.dist W 1 / 1 (100%) Time: 00:00.008, Memory: 19.22 MB OK, but there were issues! Tests: 1, Assertions: 1, Warnings: 1. ``` Commits ------- ca9f2a5 [PhpUnitBridge] Fix `DeprecationErrorHandler` with PhpUnit 10
- Loading branch information