Replace \Drupal:: with $this->container->get() in test classes of Basic Auth module

Created on 4 April 2016, about 9 years ago
Updated 7 March 2025, 3 months ago
📌 Task
Status

Needs work

Version

11.0 🔥

Component

basic_auth.module

Created by

🇮🇳India Swetha Yarla

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Pipeline finished with Success
    3 months ago
    Total: 1121s
    #442935
  • 🇪🇸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 work

    I'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.

  • 🇲🇽Mexico dalin 🇨🇦, 🇲🇽, 🌍

    dalin changed the visibility of the branch 11.x to hidden.

  • 🇲🇽Mexico dalin 🇨🇦, 🇲🇽, 🌍

    dalin changed the visibility of the branch 2699565-replace-drupal-with to hidden.

  • 🇪🇸Spain alvar0hurtad0 Cáceres

    Working on it.

  • Pipeline finished with Failed
    2 months ago
    Total: 231s
    #460786
  • Pipeline finished with Failed
    2 months ago
    Total: 677s
    #460787
  • 🇺🇸United States smustgrave

    Big auth appears to be failing.
    New parameters should be typehinted also

    If 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.

  • 🇪🇸Spain alvar0hurtad0 Cáceres

    Still working on this, I didn't forget.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 4141s
    #472428
  • 🇪🇸Spain alvar0hurtad0 Cáceres

    The test related to this are green now.

    There're some javascript test failing but I can't find any relation with the changes done in this fork.

  • Pipeline finished with Success
    about 2 months ago
    Total: 3046s
    #472480
  • 🇺🇸United States smustgrave

    Left 1 comment on MR.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 163s
    #474254
  • Pipeline finished with Success
    about 2 months ago
    Total: 434s
    #474259
  • 🇪🇸Spain alvar0hurtad0 Cáceres

    Thanks for your review and sorry for the ping pong.

  • 🇺🇸United States smustgrave

    This appears to be addressed.

  • Status changed to RTBC 18 days ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    alexpott changed the visibility of the branch 11.x to active.

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    I think we should retitle this issue. It's not really about test classes anymore. Plus I left quite a bit of feedback on the MR.

Production build 0.71.5 2024