Spotted while running the previous-major (Drupal 10) test lane on #3592825.

Problem

DomainConfigEditContextTest (added in #3592832) imports Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, which only exists in Drupal 11.1 and later. On Drupal 10.x that trait does not exist, so the class-body use statement fatals at class load:

PHP Fatal error: Trait "Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait" not found

Because the kernel test cannot load, it brings down the whole previous-major phpunit job, blocking that lane for every merge request targeting 3.x (the module declares ^10.2 || ^11).

Proposed resolution

Resolve the trait across both majors. Drupal 10.x provides Drupal\Tests\Traits\ExpectDeprecationTrait; Drupal 11.1+ provides the DeprecationBridge one and drops the old name. Alias the legacy trait to the new name when only the legacy one is present, so the test loads on both:

if (!trait_exists(ExpectDeprecationTrait::class)
  && trait_exists('Drupal\Tests\Traits\ExpectDeprecationTrait')) {
  class_alias('Drupal\Tests\Traits\ExpectDeprecationTrait', ExpectDeprecationTrait::class);
}

Remaining tasks

  • Add the cross-version alias before the class declaration.
  • Confirm the kernel test passes on Drupal 10 and Drupal 11.

Issue fork domain-3592897

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

mably created an issue. See original summary.

mably’s picture

Status: Active » Needs review

Pushed MR !387 with the fix (a cross-version class_alias so the legacy ExpectDeprecationTrait resolves on Drupal 10). Kernel test passes on Drupal 11.3 locally; the previous-major lane confirms Drupal 10. This also unblocks the previous-major lane on #3592825 / !386 once it lands in 3.x.

  • mably committed 60ff3f04 on 3.x
    fix: #3592897 DomainConfigEditContextTest fatals on Drupal 10: imports...
mably’s picture

Status: Needs review » Fixed

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.

Status: Fixed » Closed (fixed)

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