Problem/Motivation
In #3392616-5: Update to Symfony 6.4 we've found out that the Symfony\Component\DependencyInjection\ContainerAwareTrait and Symfony\Component\DependencyInjection\ContainerAwareInterface are being deprecated in Symfony 6.4 and removed in 7.0.
A number of test classes use ContainerAware for testing purposes. We should remove the trait and use dependency injection properly or inject the entire container as required.
Steps to reproduce
Proposed resolution
- Remove usage of ContainerAwareTrait from test classes
- Keep tests affected by ContainerAwareInterface until interface is used in \Drupal\Core\DependencyInjection\ClassResolver::getInstanceFromDefinition() - probably #3397522: Fork Symfony's ContainerAwareTrait and ContainerAwareInterface into core
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3421482
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:
- 3421482-remove-containerawaretrait-from-tests
changes, plain diff MR !6813
Comments
Comment #2
spokjeRetitling based on the 2nd paragraph of the IS and the fact that a similar titled issue was created just before this one (Probably copy-pasta?)
Comment #5
andypostOnly 3 tests are affected, fixed by removing trait as interface should be tested still.
Changed
ControllerResolverTestto be inline withCallableResolverTestComment #6
smustgrave commentedWonder if we should add a CR for the trait removal.
Comment #7
smustgrave commentedProbably good to self RTBC as the removal seems fine.
Comment #8
longwaveThis is only in tests, no CR needed.
Comment #9
catchShould the classes that are removing ContainerAwareTrait and implement ContainerAwareInterface also be dropping ContainerAwareInterface here too?
Comment #10
andypostI decided to leave interface as is until we remove it from controller resolver so no code remain untested
Comment #11
andypostSorry, I mean
ClassResolverhttps://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...
Comment #12
longwaveMaybe we just postpone this until we have figured out what to do with ClassResolver?
Comment #13
andypostUpdated IS with proposal
Comment #14
smustgrave commentedSo is this postponed?
Comment #15
andypostI see no reason as class resolver and its tests should be fixed in other issue but this one is clean-up of useless places
Comment #16
smustgrave commentedIn that case removal seems fine.
Comment #17
longwaveOK yeah let's do this here and decide what to do with the class resolver later.
Comment #20
catchOK fair enough. Committed/pushed to 11.x and cherry-picked to 10.3.x, thanks!