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
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
mably commentedPushed 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.
Comment #5
mably commented