- Merge request !11414Issue #2699565: Replace \Drupal:: with $this->container->get() in test classes of Basic Auth module → (Open) created by alvar0hurtad0
- 🇪🇸Spain alvar0hurtad0 Cáceres
Hello,
Since a lot of things changed in the tests during the last 8 years I think we can focus on the scope of the issue and create a follow up issue to check if the component follows the recommendations in https://www.drupal.org/project/drupal/issues/2066993 🌱 Use \Drupal consistently in tests Needs workI've created a MR with the requirements in this issue.
- 🇺🇸United States smustgrave
Thanks for reviving the issue.
For good practice we should have a full summary template be used, explaining why this is needed.
Standard issue template is fine and if sections don't apply you can leave blank or better leave NA
- 🇦🇺Australia realityloop
Creating an issue summary is a great Novice task for Contribution workshop at Drupalcon
- daniel_mm02 Burriana, Castellón
Hi everyone, I've updated the issue summary with the necessary details regarding the replacement of
\Drupal::
with$this->container->get()
in our test classes. - 🇮🇳India Sivaji_Ganesh_Jojodae Chennai
Inside
core/modules/basic_auth/tests
I can still find the usage of\Drupal::
. Should we change the following occurances as well?./modules/basic_auth_test/src/BasicAuthTestController.php:16: \Drupal::state()->set('basic_auth_test.state.controller_executed', TRUE); ./modules/basic_auth_test/src/BasicAuthTestController.php:25: \Drupal::service('page_cache_kill_switch')->trigger(); ./modules/basic_auth_test/src/BasicAuthTestController.php:28: '#markup' => \Drupal::state()->get('basic_auth_test.state.controller_executed') ? 'yep' : 'nope',
- 🇬🇧United Kingdom alexpott 🇪🇺🌍
Functional tests should use \Drupal KernelTests should not. so the issue title is incorrect. Sure we can inject services correctly into the controller...
- 🇲🇽Mexico dalin 🇨🇦, 🇲🇽, 🌍
I'm at DrupalCon Atlanta2025 and I tried to sit down with a novice, but it turned out to be a bit much. I'm going to remove the Novice tag because this requires first understanding unit tests, dependency injection, and the difference between kernel tests and functional tests. Even though in the end we'll only be changing a few characters.
- 🇺🇸United States smustgrave
Big auth appears to be failing.
New parameters should be typehinted alsoIf you are another contributor eager to jump in, please allow the previous poster(s) at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!
- 🇪🇸Spain alvar0hurtad0 Cáceres
Hi ,
I'd like to finish it, but I don't get your comment Smustgrave. I'm sorry if I'm doing anything incorrect.
If I'm should stop contributing here, please let me know. I just want to get more involved in code contributions, but I don't want to bother anyone. - 🇺🇸United States smustgrave
You’re completely good! And doesn’t bother anyone
If you click into the pipeline you’ll see a functional test for big auth is failing so the change may need to be tweaked
The functional JavaScript failure is most likely random and just needs to be re ran
- 🇪🇸Spain alvar0hurtad0 Cáceres
Thanks for the clarification, Stephen.
:)
Working on it.