Problem/Motivation
The test classes in the Basic Auth module are using static calls to \Drupal::
, which does not follow Drupal's recommended dependency injection practices. This makes the code less extensible, harder to maintain, and may cause issues in testing environments by not properly leveraging the service container.
Steps to reproduce
- Clone or access the Basic Auth module repository.
- Navigate to the directory containing the test classes.
- Search for instances of
\Drupal::
within these classes. - Run the test suite and observe potential warnings or errors related to dependency injection.
Proposed resolution
Refactor any kernel tests (functional/browser tests are fine as per #27) in Basic Auth module the test classes to replace \Drupal::
calls with $this->container->get()
. This change will align the code with modern dependency injection practices in Drupal.
Remaining tasks
- Alter the tests.
- Run the tests to confirm that no regressions or side effects have been introduced.
- Conduct a code review to ensure the change does not negatively affect test execution.
User interface changes
None
Introduced terminology
None
API changes
None
Data model changes
None
Release notes snippet
The test classes in the Basic Auth module have been refactored to use $this->container->get()
instead of \Drupal::
, aligning with best practices for dependency injection in Drupal.