phpunit

How to display deprecations with phpunit 11.5


I use Symfony 6.4 on php8.3 and there is this one test, which shows that I have deprecations, but not where or what they are. I use phpunit 11.5 This is my phpunit.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
         colors="true"
         bootstrap="tests/bootstrap.php"
         cacheResult="false"
         executionOrder="default"
         displayDetailsOnTestsThatTriggerDeprecations="true"
         displayDetailsOnTestsThatTriggerErrors="true"
         displayDetailsOnTestsThatTriggerNotices="true"
         displayDetailsOnTestsThatTriggerWarnings="true"
         displayDetailsOnPhpunitDeprecations="true"
         cacheDirectory=".phpunit.cache"
         testdox="false">
    <php>
        <ini name="error_reporting" value="-1"/>
        <server name="APP_ENV" value="test" force="true"/>
        <server name="SHELL_VERBOSITY" value="-1"/>
        <server name="KERNEL_CLASS" value="App\Kernel"/>
        <server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
        <env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
        <env name="CORS_ALLOW_ORIGIN" value="^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$"/>
    </php>
    <extensions>
        <bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
    </extensions>
    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>tests</directory>
        </testsuite>
    </testsuites>
    <source>
        <include>
            <directory>src</directory>
        </include>
    </source>
</phpunit>

This is the result when I run the test:

$ bin/phpunit tests/Controller/PlaceholderControllerTest.php
PHPUnit 11.5.0 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.10
Configuration: /var/www/phpunit.xml

..                                                                  2 / 2 (100%)

Time: 00:00.771, Memory: 10.00 MB

OK (2 tests, 5 assertions)

Remaining direct deprecation notices (12)

What setting should I change so that more information about the deprecations are shown? As you see I already have the option active, which displays deprecations and testdox is set to false. I also tried removing textdox completely from the config. Nothing changes.

Edit: I also tried calling the test like this without a phpunit.xml file present and still no details:

$ bin/phpunit tests/Controller/PlaceholderControllerTest.php --display-deprecations --display-phpunit-deprecations
PHPUnit 11.5.0 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.10
Configuration: /var/www/phpunit.xml.dist

..                                                                  2 / 2 (100%)

Time: 00:00.678, Memory: 10.00 MB

OK (2 tests, 5 assertions)

Remaining direct deprecation notices (12)

Solution

  • The message "Remaining direct deprecation notices" is from Symfony's PHPUnit Bridge.
    This line here would prevent the verbose output

    See their documentation at https://symfony.com/doc/current/components/phpunit_bridge.html#configuration

    The verbose output should be enabled by default. However to make sure, set this in the phpunit.xml file

    <env name="SYMFONY_DEPRECATIONS_HELPER" value="0"/>