Problem/Motivation

PHPUnit 13.2 deprecates TestCase::expectExceptionMessage() in favor of TestCase::expectExceptionMessageIs() (stricter) or TestCase::expectExceptionMessageIsOrContains() (equivalent to TestCase::expectExceptionMessage()).

See Improved API for exception message expectations

Proposed resolution

Replace additions that occurred recently.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3629594

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.

wkr1shna’s picture

Assigned: Unassigned » wkr1shna

Hey! i would love to give this a shot, Assigning this to myself!!

wkr1shna’s picture

Status: Active » Needs review

THe failed php builds seems out of scope and not related to my changes, Marking this for review!!

mondrake’s picture

Thank you @wkr1shna!

Sorry, I had already work done for this on #3574681: [Nov 2026] Introduce support for PHPUnit 13.5, so it's easier for me to dump it here rather then review your input. Let's restart from here.

If you are interested on getting PHPUnit 13 in Drupal, there's plenty of work to do! You can look at open issues tagged 'PHPUnit 13', or at the current failures of #3574681: [Nov 2026] Introduce support for PHPUnit 13.5 and open issues for the things that are failing.

wkr1shna’s picture

Assigned: wkr1shna » Unassigned

Thank you for the guidance! No worries at all. I’m definitely interested in contributing further to the PHPUnit 13 effort. I’ll go through the open issues and current failures to find something I can work on.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

All of the code changes look correct. Observant reviewers may notice that there are a few instances where expectExceptionMessageIs() is already in use and the expected message is being changed. That's because those messages are incorrect. You have to test with PHPUnit 13.2+ to get those failures. The easiest way to do that is to install the MR from #3574681: [Nov 2026] Introduce support for PHPUnit 13.5, revert the changes to those tests, then run the tests. You'll get failures noting that the exception messages are incorrect.

I also grepped Core for any remaining instances of expectExceptionMessage(). The only two left are in ForwardCompatibilityTrait.

This looks good to me.

  • mstrelan committed 6cc7ccc7 on main
    task: #3629594 PHPUnit 13.2 - Replace expectExceptionMessage() with...
mstrelan’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 6cc7ccc7e21 to main. Thanks!

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

Status: Fixed » Patch (to be ported)

This would need a backport to 12.0 for #3574681: [Nov 2026] Introduce support for PHPUnit 13.5.

mstrelan’s picture

Version: main » 12.0.x-dev
mstrelan’s picture

FYI this doesn't backport cleanly so will need a new MR:

$ git cherry-pick -x 6cc7ccc7e21cef7bc6c32572d9f8bbb12e86720d
CONFLICT (modify/delete): core/tests/Drupal/KernelTests/Core/Recipe/RecipeFinderTest.php deleted in HEAD and modified in 6cc7ccc7e21 (task: #3629594 PHPUnit 13.2 - Replace expectExceptionMessage() with expectExceptionMessageIs*() - later additions).  Version 6cc7ccc7e21 (task: #3629594 PHPUnit 13.2 - Replace expectExceptionMessage() with expectExceptionMessageIs*() - later additions) of core/tests/Drupal/KernelTests/Core/Recipe/RecipeFinderTest.php left in tree.
Auto-merging core/tests/Drupal/Tests/Core/Database/SchemaDefinitionTest.php
CONFLICT (content): Merge conflict in core/tests/Drupal/Tests/Core/Database/SchemaDefinitionTest.php
error: could not apply 6cc7ccc7e21... task: #3629594 PHPUnit 13.2 - Replace expectExceptionMessage() with expectExceptionMessageIs*() - later additions

mondrake’s picture

Status: Patch (to be ported) » Needs review

Backport. There have been a couple of commits that were main only, and the MR for main was including fixes for those, that are missing in 12.0.x.