Description
PHPUnit 10 brings both several changes to the configuration file and a misfeature of causing phpunit
to exit with a non-zero status if the config file does not strictly validate.
So, for example, if you had been relying on convert{X}ToExceptions="true"
, you might want to set displayDetailsOnTestsThatTrigger{X}="true"
and failOn{X}="true"
for PHPUnit 10 to maintain that behavior going forward. But unless you also remove convert{X}ToExceptions="true"
, changing the behavior for runs with earlier versions of PHP, PHPUnit 10 will whine about not recognizing the old setting and will exit with a failure status even if all actual tests pass.
I don't know what the best way around this might be.
Simplest might be to provide a wrapper script that, if not passed -c
or --configuration
or --no-configuration
, looks for various config file names and picks the best one for the current version of PHPUnit to set --configuration
before execing phpunit
. For example, it might check for any "phpunit.{VER}.xml.dist" and pick the one with the highest {VER}
that's not greater than PHPUnit's own version.
A little fancier might be a wrapper that determines the configuration file in the same way PHPUnit would, copies it to a temporary file while stripping a predefined list of settings based on the PHPUnit version, and calls phpunit
with --configuration
pointing to the temporary file.
Unfortunately PHPUnit doesn't provide any way to hook into its own code to handle things more directly. There might still be ways, but they'd be fragile.