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

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

kingdutch created an issue. See original summary.

kingdutch’s picture

mondrake’s picture

One comment inline. Otherwise looks good.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Backport to 11.x requires a new MR to also backport the two MR that were only committed to main.

kingdutch’s picture

Issue tags: +Major version only

Tagging "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

alexpott’s picture

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

Committed and pushed f542f29445d to main. Thanks!

mondrake’s picture

Version: 11.x-dev » main
Status: Patch (to be ported) » Fixed

backport in #3590435: Backport changes to DrupalTestCaseTrait and related classes from 12.x to 11.x as it requires combined backporting with other commits.

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.

  • alexpott committed f542f294 on main
    task: #3590425 Remove usage of property hook for DrupalTestCaseTrait::$...

Status: Fixed » Closed (fixed)

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