Problem/Motivation

PHPUnit 10 is out of bugfix support. Drupal core 11.2 is being tested with PHPUnit 11, but retained (albeit with some difficulty) allowing downgrading to PHPUnit 10. Current (Sep 2025) PHPUnit release is 12, and 13 is expected in 5 months.

Some issues already are introducing PHPUnit 11+ features and are blocked by the PHPUnit 10 BC.

Proposed resolution

Drop support for PHPUnit 10. This involves removing the compatibility layers so once done, neither core nor contrib will be able to run tests under PHPUnit 10.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Framework support for testing with PHPUnit 10 is removed. Both core and contrib can now only run tests with PHPUnit 11.

Test classes using annotation metadata still work under PHPUnit 11, but throw PHPUnit deprecations that lead to CI job failures if appropriately set up. It is strongly recommended to convert annotations to attributes as described in Tests with PHPUnit 10 attributes are now supported.

Issue fork drupal-3537104

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mondrake created an issue. See original summary.

godotislate’s picture

Following up from #3531287: Remove core/recommended constraint for sebastian/diff here: with PHP10 support removed, consider restoring the core-recommended composer.json constraint on sebastian/diff.

mondrake’s picture

Issue tags: +PHPUnit 11, +PHPUnit 12
mondrake’s picture

Issue summary: View changes
mondrake’s picture

Status: Active » Needs review
mondrake’s picture

mondrake’s picture

Not sure about #2. If we readd here, we may need to remove again in a few months while adjusting for PHPUnit 12.

longwave’s picture

I asked in #maintainers in Slack, and those who responded were largely unaware that we had moved to PHPUnit 11 even, but their code was still working fine, or they had had to make minimal changes. I think we should give it a few more days but it seems so far that dropping PHPUnit 10 support won't be a problem even though it is technically a BC break.

I will credit those who contributed to the discussion, but will wait a few more days for any more responses before removing the RM review tag.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Needs review

rebased

longwave’s picture

Only one further comment was received, agreeing that they had not noticed any difference with PHPUnit 11. Given there has been no disagreement to the plan I think it's fine to move forwards with this.

mondrake’s picture

Added draft CR https://www.drupal.org/node/3546970, bare bone.

mondrake’s picture

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Needs review
godotislate’s picture

Status: Needs review » Needs work

MR is pretty straightforward. At first I wondered about moving the following outside the loop, but I think it's actually more efficient this way. I guess this technically could be converted to an arrow function, but that's a person code style preference thing

    $groups = array_filter(array_unique($tmp), function (string $value): bool {
      return !str_starts_with($value, '__phpunit');
    });

I searched through the existing 11.x codebase for /phpunit.?10/, and I found a few references that might need updating:
composer/Generator/Builder/DrupalCoreRecommendedBuilder.php:

      // Remove constraint to allow sites to use PHPUnit 10 or 11, which require
      // different major versions of this package.
      // @todo Restore constraint when PHPUnit 10 is no longer supported?
      // @see https://www.drupal.org/project/drupal/issues/3537104
      'sebastian/diff',

I think this one was addressed in #8, which makes sense, but then this @todo and @see needs to be edited or removed.

core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php:
// PHPUnit 10 cannot expect warnings, so we have to catch them ourselves.

core/tests/Drupal/Tests/Core/Theme/Icon/IconFinderTest.php:

    // PHPUnit 10 cannot expect warnings, so we have to catch them ourselves.
    // Thanks to: Drupal\Tests\Component\PhpStorage\FileStorageTest.

core/tests/Drupal/TestTools/Extension/DeprecationBridge/DeprecationHandler.php:

 * This class is a replacement for symfony/phpunit-bridge that does not
 * support PHPUnit 10. In the future this extension might be dropped if
 * PHPUnit adds support for all deprecation management needs.

core/tests/Drupal/TestTools/Extension/DeprecationBridge/ExpectDeprecationTrait.php:

 * This trait is a replacement for symfony/phpunit-bridge that is not
 * supporting PHPUnit 10. In the future this extension might be dropped if
 * PHPUnit will support all deprecation management needs.

Also looked at the CR, which looks mostly fine, but I think this sentence is not clear.

PHPUnit 12 removes support for annotations, and in preparation issues to support it Drupal 11's PHPUnit framework may stop working properly if annotations are still in use.

mondrake’s picture

Assigned: Unassigned » mondrake
Status: Needs work » Postponed
Related issues: +#3547173: Complete test annotations to attributes conversion for all remaining tests

Thanks a lot for the review. I'll be addressing the points in #19.

Anyway, let's postpone on #3547173: Complete test annotations to attributes conversion for all remaining tests that is completing the transition from annotation to attributes, and is tagged for avoiding commit conflicts.

mondrake’s picture

Addressed feedback in #19 and edited the draft CR, hopefully for the good.

mondrake’s picture

Assigned: mondrake » Unassigned
godotislate’s picture

I think the MR and CR look good now. Once unpostponed, should be good for RTBC unless there are significant rebase issues.

mondrake’s picture

Status: Postponed » Needs review

Unblocked

godotislate’s picture

Status: Needs review » Reviewed & tested by the community

lgtm

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Reviewed & tested by the community

rebased - any dependency update will cause merge errors here, unfortunately

mondrake’s picture

  • catch committed e97f59b6 on 11.3.x
    Issue #3537104 by mondrake, godotislate, longwave, megachriz,...
catch’s picture

I think @longwave's slack survey in #9 is the best we can do here and more than a month has passed.

Committed/pushed to 11.x and cherry-picked to 11.3.x, thanks!

  • catch committed 4a715bfd on 11.x
    Issue #3537104 by mondrake, godotislate, longwave, megachriz,...

catch’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

mondrake’s picture

Issue summary: View changes

Adding a release snippet in case it's needed

catch’s picture

Added to the release notes draft https://docs.google.com/document/d/1YOayaWh5qf6ilLpnQtD36AovZ6ii4_9ssdmi...

Release notes are mainly for site owners, but some do have phpunit tests and we don't have a long list of release notes at the moment.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.