Disable symfony deprecation warnings in PHPUnit tests

Symfony’s deprecation warnings while running tests is a great service to keep track with upcoming changes in newer symfony versions.
However these warnings can break your CI/CD pipeline and sometimes you cant fix all deprecation warnings immediatly.

To disable them you can set the ENV var
SYMFONY_DEPRECATIONS_HELPER=disabled
and the warnings will not be displayed anymore and CI/CD will pass again.
Update from comments:

SYMFONY_DEPRECATIONS_HELPER=weak
does also work and will still show the deprecation warnings count. (Thx Max)

This was introduced a while ago with this PullRequest and works for symfony >= 3.1.

So for running the tests manually, do like this:

SYMFONY_DEPRECATIONS_HELPER=disabled vendor/bin/phpunit

Or add it to the phpunit.xml

<php>
    <ini name="error_reporting" value="-1" />
    <env name="KERNEL_CLASS" value="App\Kernel" />
    ...
    <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
</php>

With bitbucket pipelines it looks like this:

pipelines:
branches:
master:
- step:
script:
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer install
- SYMFONY_DEPRECATIONS_HELPER=disabled composer test
- composer check-style

2 Replies to “Disable symfony deprecation warnings in PHPUnit tests”

Comments are closed.