Problem/Motivation
#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 are working to change where app_root and siteDirectory gets managed in DrupalKernel and in tests.
#3589047: Deprecate TestRequirementsTrait::getDrupalRoot() and #3573954: Move common code across Drupal base test suite classes to DrupalTestCaseTrait have made changes that have only landed in main and create a difference in how $root works in tests. This makes refactoring with the aim of a minor release significantly more difficult.
Steps to reproduce
Proposed resolution
Initialize the $root property in a #[Before] hook with high priority so that it's available for all test setup that may be needed.
Deprecation of altering the $root property is postponed to a 12.x version after backporting to 11.x is no longer considered necessary. This can then be done by reintroducing the property hook and removing the internal setUpRoot.
setUpRoot is declared final to prevent overriding, providing a single deprecation path if root is being set directly in contrib tests (this currently doesn't happen in core). With either #1792310: Wrong DRUPAL_ROOT with non-standard code structure or #2529170: [PP-1] Remove DrupalKernel::initializeRequestGlobals and replace base_root, base_url and base_path with a service landing, test would have other methods to affect the application root, even if they can not set $root directly.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3590425
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
Comment #3
kingdutchComment #4
kingdutchOne incorrect related issue.
Comment #5
mondrakeOne comment inline. Otherwise looks good.
Comment #6
mondrakeBackport to 11.x requires a new MR to also backport the two MR that were only committed to main.
Comment #7
kingdutchTagging "Major version only" as per #6, since this issue shouldn't be backported when merging.
Backport of the previous two issues with this one happens in #3590435: Backport changes to DrupalTestCaseTrait and related classes from 12.x to 11.x
Comment #8
alexpottCommitted and pushed f542f29445d to main. Thanks!
Comment #9
mondrakebackport in #3590435: Backport changes to DrupalTestCaseTrait and related classes from 12.x to 11.x as it requires combined backporting with other commits.