Deprecations Handling Improvements with v7.16.0 (for PHPUnit 9) #97
Replies: 1 comment 12 replies
-
|
Just today I was investigating this (whilst preparing my package for PHP 8.4) and I'm currently super confused how things are supposed to be handled. What I (think) I know:
So recommendations like using Using this I noticed such logging produces a stacktrace on every hit, which isn't really useful (the message contains the source of the PHP deprecation trigger) but I can't turn off Maybe I'm also mixing things up, but is there a way doing things "the phpunit way" or is "enabling sideband logging during tests" the way forward with Laravel here? thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The upcoming release will introduce Deprecation Handling Improvements and may cause your packages CI to start failing especially if you have configured
phpunit.xmlconfiguration withconvertDeprecationsToExceptions="true".In the past,
Illuminate\Foundation\Bootstrap\HandleExceptionshandles all errors includingE_DEPRECATEDandE_USER_DEPRECATEDand convert it into logs. This works great to reduce deprecation warnings during development but isn't useful for Packages development where you want to actually see the deprecation warnings/exceptions.Coming with 7.16.0, you should be able to do the following:
convertDeprecationsToExceptions="false"Output to Spatie Ray
In order to do this, you just need to add the following environment variables to
phpunit.xmlor CI pipeline:Output deprecations logs to
stderrYou can also setup Laravel's logger to output deprecation warnings to specific logger channel such as
stderr:Throws using Laravel's exception.
This would throws
Orchestra\Testbench\Exceptions\DeprecatedExceptionwhen you add the following environment variable:TESTBENCH_CONVERT_DEPRECATIONS_TO_EXCEPTIONS=trueconvertDeprecationsToExceptions="true"By default, all deprecation exception will throws
Orchestra\Testbench\Exceptions\DeprecatedExceptioninstead ofPHPUnit\Framework\Error\Deprecated. SettingTESTBENCH_CONVERT_DEPRECATIONS_TO_EXCEPTIONSenvironment variable totruehas no additional affect.Completely exclude throwing exceptions
There might be CI build where you might want to exclude throwing deprecation exceptions such as
--prefer-lowestbuilds. In this cause you may add the following environment variable to the build:TESTBENCH_CONVERT_DEPRECATIONS_TO_EXCEPTIONS=falseBeta Was this translation helpful? Give feedback.
All reactions