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
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:
- 3594028-11x
changes, plain diff MR !16305
- 3594028-phpunit-13.2--
changes, plain diff MR !16004
Comments
Comment #2
mondrakeComment #3
mondrakeComment #5
mondrakeComment #6
mondrakeComment #7
mondrakeComment #8
amitgoyal commentedReviewed 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.
Comment #9
catchCommitted/pushed to main, thanks!
Will need a backport MR for 11.x.
Comment #13
mondrakeComment #14
smustgrave commentedLooks like a good backport
Comment #16
catchCommitted/pushed to 11.x, thanks!