Closed (fixed)
Project:
Drupal core
Version:
main
Component:
phpunit
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Feb 2026 at 11:27 UTC
Updated:
29 May 2026 at 12:55 UTC
Jump to comment: Most recent
Comments
Comment #3
mondrakeI was thinking to try and streamline how
$this->rootis populated across the different base classes, but not sure it's worth the effort. Feedback appreciated.Comment #4
mondrakeFor now, only moved
setDebugDumpHandleras it was the same code repeated in three separate classes.Comment #5
smustgrave commentedSeems straight forward
Comment #6
mondrakeThanks @smustgrave. I think we may move
::getDrupalRoot()into the new trait and deprecateTestRequirementsTrait- that trait is no longer doing what it says in the docs. Thoughts?Comment #7
mondrakeNow the resolution of the $root property in tests to indicate the root path to Drupal has been hubbed into the new trait with a hooked property that we can use in D12 that has PHP 8.5 minimum.
ATM I added bypasses for PHPStan and PHPCS as they still have failures with hooked properties.
But the concept of the MR is reviewable.
Comment #8
mondrakePHPStan failures are now gone after commit of #3575792: Bump PHPStan & friends to latest release.
Comment #9
mondrakeCode uses property hooks, so can't target D11.
Comment #10
smustgrave commentedSorry this one appears to need a rebase. If you ping me I can try and review faster. Review queue stays having 250 items in it lol .
Comment #11
mondrakeRebased.
Comment #12
smustgrave commentedThanks for the quick rebase. Could the CR get an update?
Comment #13
mondrakeCR updated.
Comment #14
smustgrave commentedIn that case I have no additional feedback.
Not sure if we want follow ups for what you and joachim were discussing in slack about.
Comment #15
dcam commentedSorry guys. I was reviewing while that conversation was taking place. I found one issue and one minor suggestion/question.
Comment #16
dcam commentedFor what it's worth, this is really interesting. It's the first use of property hooks that I've personally seen in the wild. Conceptually, I think this is great. I like that we're cutting out duplication.
Comment #17
mondrakeThanks!
Addressed @dcam points.
This is the link to the slack discussion: https://drupal.slack.com/archives/C079NQPQUEN/p1775051492082049
IMHO that's unrelated to this. If someone wants to move those classes, feel free to file issues.
Comment #18
dcam commentedThank you for considering my feedback. This looks good to me.
Comment #20
quietone commentedI triaged this issue and found everything in order and no unanswered questions. I have updated credit.
I applied two suggestions to DrupalTestCaseTrait which was to move the "@todo" and the "phpcs:ignoreFile" lines to the top of the file. That was just to conform to the other instances of "phpcs:ignoreFile" is core.
Comment #21
longwaveAlways nice to see these little cleanups going in, making things incrementally better.
Committed and pushed fe682bee7a2 to main. Thanks!
Comment #25
quietone commentedPublish the CR
Comment #26
kingdutchThis was tagged as major version only which makes other in-flight work that's trying to change how app-root works in a BC way for a minor version quite a bit more challenging, because there's no standardised way in tests across 11.x and 12.x that Drupal now uses to get the root and the new hardcoded root for
DrupalTestCaseTrait::$rootexists only in 12.x and not in 11.x, which usesTestRequirementsTraitand various other methods.Paragraph removed since the trait isn't actually new.
Additionally the newDrupalTestCaseTraitcauses some confusion withTestSetupTraitwhich lives inDrupal\Core\Testand seems to be for public consumption since it's in the lib. However, the use-case of that trait seems to be more narrow. The similar naming may cause some confusion and the goals seem to have some overlap. I don't see any discussion around this in the issue and it may be good to still have that.But my main question is whether this can be backported to Drupal 11, even though that may require not using property hooks. So that it does not block the work for #1792310: Wrong DRUPAL_ROOT with non-standard code structure and #2529170: [PP-1] Remove DrupalKernel::initializeRequestGlobals and replace base_root, base_url and base_path with a service.