We could use more test coverage for this module. There are a lot of users, a lot of configuration options, and a lot of open issues.
To start, the existing tests could use some TLC. I'd like to start with the kernel test EasyBreadcrumbBuilderTest.
- Consolidate duplicated code
- Remove calls to \Drupal
This should reduce the file by about 100 lines and improve readability.
Issue fork easy_breadcrumb-3612936
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
loopduplicate commentedComment #5
csakiistvanComment #6
csakiistvanEnvironment
da98433)Prerequisites
2.xbranch.2.x:Steps
EasyBreadcrumbBuilderconstruction into a shared helper, add helpers for building and asserting the custom-path breadcrumb, and replace all static\Drupal::calls with$this->container->get().ddev drush crtests/src/Kernel/EasyBreadcrumbBuilderTest.phpagainst the baseline.Expected results
\Drupal::calls in the test file.Actual results
The refactor achieves its goals. The kernel test still passes with exactly the same coverage as before (12 tests, 112 assertions, unchanged deprecation counts), the file shrinks from 409 to 310 lines (99 lines removed, matching the roughly 100 lines predicted in the issue summary), and all 140 lines containing static
\Drupal::calls are gone. The consolidation intogetEasyBreadcrumbBuilder(),getBreadcrumbByCustomRoute()andassertCustomPath()is a clear readability win.Two problems were found in the first round of testing, at commit
3bd0fa9, and have since been fixed on the branch:$router = $this->container->get('router.no_access_checks');;— pushing phpcs from 5 errors / 2 warnings up to 7 errors / 4 warnings. This was visible on the MR pipeline too: thephpcsjob failed on pipeline 901101, and only avoided turning the pipeline red because that job is configured withallow_failure: true.@param Drupal\Core\Routing\RequestContextRequestContext $request_context(duplicated class name), plus@param/@returntypes written without a leading backslash, so none of them resolved.Both were corrected in commit
281803e. A follow-up commit1051c64also cleared the 5 errors and 2 warnings that pre-dated this issue in the same file (docblock indentation, a summary line over 80 characters, and two lowercasetrueliterals), so the file is now fully clean.Final state on the branch: phpcs reports no errors and no warnings, and the kernel test passes with 12 tests and 112 assertions — identical coverage to the baseline.
Testing produced with the assistance of an LLM.
Comment #9
loopduplicate commentedthank you @csakiistvan
Comment #11
csakiistvanWelcome @loopduplicate :)