Fixed
Project:
Drupal core
Version:
12.0.x-dev
Component:
phpunit
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
27 Jul 2026 at 11:18 UTC
Updated:
9 Oct 2026 at 08:02 UTC
Jump to comment: Most recent
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
Focus on tests from the unit-component test suite and for tests extending directly from TestCase in this issue.
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
Comment #5
mondrakeComment #6
dcam commentedI found one issue with a failing test. Please review my comment on the MR.
Otherwise the changes look good. All uses of
expectExceptionMessage()are replaced in the Component tests.Comment #7
mondrakeComment #8
mondrakeComment #9
dcam commentedOh. Of course. Yes, I was testing on 13.2.5. 🙄
I reran the tests on 13.2.5. There were no failures this time. I think this is good to go.
Comment #10
catchNot sure about using the trait in the test classes.
The idea behind the components is that they add implicit dependencies (or any dependencies) on code from other namespaces, but the test trait does this. Do we need to add drupal/core to require-dev or something?
Comment #11
mondrake#10 sounds like another reason to do #3614056: Define Drupal\TestTools namespace in root composer.json or something similar?
Comment #12
mondrakeThe trait would be temporary until we bump to PHPUnit 13, though. We will have to remove it at that time, since the new methods in PHPUnit 13 are final and we would get fatals if we don’t.
Comment #13
mondrakeComment #14
dcam commentedI admit that I don't understand the point that was made in #10. But since a response was given to it, the issue is a blocker, and this has not been followed-up on in over a month I'm going to restore the RTBC status. FWIW it makes sense to me that we would have this temporary trait so that we can get started on these expectation conversions sooner.
Comment #17
catchAh sorry I missed the reply. Absolutely a good idea to move back to RTBC when the question is answered.
So the components directory is supposed to be self-contained, the code in there can depend on other components and not
Drupal\Core. All the way before Drupal 8 was released the idea was to move more and more core code to components, which if it's happening is only happening at a glacial pace but also we've kept to that rule for the code that's there afaik and gradually moved a few things into it.But... the tests for the components are in core/tests, not within the components themselves, and also given that this is temporary, it will be gone eventually anyway, so we shouldn't worry about it. And #3614056: Define Drupal\TestTools namespace in root composer.json is enough to maybe clean this up later.
Committed/pushed to main and 12.0.x, thanks!
I'm not sure if we need a backport to 11.x at this point, so marking fixed but please re-open if you think we do (did check, and it doesn't cherry-pick cleanly).
Comment #19
mondrakefwiw, when we used to have the PHPUnitCompatibility trait before we bumped PHPUnit to 12, that was living (and still is in D11) in the TestTools namespace anyway.
core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit11