Skip to content

Commit bb21d40

Browse files
committed
Add PHPUnit test bootstrap to silence exception-handler risky warnings
Register Symfony's `ErrorHandler` in `tests/bootstrap.php` and point `phpunit.xml.dist` at it, removing the "did not remove its own exception handlers" risky warnings on PHP 8.4/8.5. Add `symfony/error-handler` to require-dev so the bootstrap no longer relies on a transitive dependency.
1 parent 7b829d8 commit bb21d40

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"symfony/css-selector": "^5.4 || ^6.0 || ^7.0 || ^8.0",
4848
"symfony/doctrine-bridge": "^5.4 || ^6.0 || ^7.0 || ^8.0",
4949
"symfony/dom-crawler": "^5.4 || ^6.0 || ^7.0 || ^8.0",
50+
"symfony/error-handler": "^5.4 || ^6.0 || ^7.0 || ^8.0",
5051
"symfony/form": "^5.4 || ^6.0 || ^7.0 || ^8.0",
5152
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0 || ^8.0",
5253
"symfony/phpunit-bridge": "^7.3",

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5-
bootstrap="vendor/autoload.php"
5+
bootstrap="tests/bootstrap.php"
66
colors="true">
77
<testsuites>
88
<testsuite name="VichUploaderBundle Test Suite">

tests/bootstrap.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
use Symfony\Component\ErrorHandler\ErrorHandler;
4+
5+
require \dirname(__DIR__).'/vendor/autoload.php';
6+
7+
// see https://github.com/symfony/symfony/issues/53812#issuecomment-1962740145
8+
\set_exception_handler([new ErrorHandler(), 'handleException']);

0 commit comments

Comments
 (0)