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 instances of TestCase::expectExceptionMessage() in core with a forward-compatibility implementation placed in DrupalCaseTrait.

Exclude tests from the unit-component test suite and for tests extending directly from TestCase for the moment.

Replace with the stricter TestCase::expectExceptionMessageIs() in this issue, narrow to TestCase::expectExceptionMessageIsOrContains() in a follow up issue when we can check the actual failures (in the FC layer, both TestCase::expectExceptionMessageIs() and TestCase::expectExceptionMessageIsOrContains() just bounce to TestCase::expectExceptionMessage()).

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3594028

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.

mondrake’s picture

Title: PHPUnit 13.2 - Replace expectExceptionMessage() with expectExcpetionMessageIs*() » PHPUnit 13.2 - Replace expectExceptionMessage() with expectExceptionMessageIs*()
mondrake’s picture

Issue tags: +PHPUnit 13

mondrake’s picture

Issue summary: View changes
Status: Active » Needs review
mondrake’s picture

Issue summary: View changes
mondrake’s picture

amitgoyal’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed the MR. The approach is correct: forward-compatibility shims expectExceptionMessageIs() and expectExceptionMessageIsOrContains() are added to DrupalTestCaseTrait, both delegating to expectExceptionMessage() under PHPUnit 12. All 279 affected test files are updated consistently.

CI passes. No open reviewer threads. PHPCS clean. Tested locally: TestSetupTraitTest, WebAssertTest, and ConfigActionsTest all pass.

The fix for TestSetupTraitTest (adding the expectExceptionMessage() stub to the anonymous class) is correct and necessary.

LGTM.

catch’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed/pushed to main, thanks!

Will need a backport MR for 11.x.

  • catch committed 3d909ba6 on main
    task: #3594028 PHPUnit 13.2 - Replace expectExceptionMessage() with...

mondrake’s picture

Status: Patch (to be ported) » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Looks like a good backport

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x, 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.

  • catch committed 62a252ba on 11.x
    task: #3594028 PHPUnit 13.2 - Replace expectExceptionMessage() with...

Status: Fixed » Closed (fixed)

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