There currently is no test for the "Include the current page as a segment in the breadcrumb" (INCLUDE_TITLE_SEGMENT) config.

Command icon 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

loopduplicate created an issue. See original summary.

loopduplicate’s picture

Assigned: loopduplicate » Unassigned
Status: Active » Needs review
Issue tags: -Needs test
csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

Status: Needs review » Reviewed & tested by the community

Environment

  • Drupal: 11.4.4
  • PHP: 8.5.5
  • Database: MariaDB 10.11.16
  • DDEV: v1.25.2
  • Easy Breadcrumb: 2.x-dev (c68c5f0, MR !196)
  • Browser: Chrome

Prerequisites

  • Enable the module:
    ddev drush en easy_breadcrumb -y
  • Use an admin theme that renders the breadcrumb block, for example Claro:
    ddev drush config:set system.theme admin claro -y
  • Keep the module defaults for the related settings, so both the home and the title segment are rendered:
    ddev drush config:set easy_breadcrumb.settings include_home_segment true -y
    ddev drush config:set easy_breadcrumb.settings include_title_segment true -y
  • This is a test-only issue, so there is no user-facing behaviour change. The behaviour asserted by the new test was verified manually in the browser as well.

Steps

  1. Apply the fix from MR !196: it adds the functional test tests/src/Functional/EasyBreadcrumbIncludeTitleSegmentTest.php, which places the breadcrumb block, toggles the Include the current page as a segment in the breadcrumb setting on and off, and asserts the second breadcrumb segment on /admin.
  2. Rebuild caches:
    ddev drush cr
  3. Run the new test:
    ddev exec 'cd /var/www/html/web && ../vendor/bin/phpunit -c core/phpunit.xml.dist modules/contrib/easy_breadcrumb/tests/src/Functional/EasyBreadcrumbIncludeTitleSegmentTest.php'
  4. Check the coding standards of the new file:
    ddev exec 'cd /var/www/html && vendor/bin/phpcs --standard=Drupal,DrupalPractice web/modules/contrib/easy_breadcrumb/tests/src/Functional/EasyBreadcrumbIncludeTitleSegmentTest.php'
  5. Verify the same behaviour manually: with the Include the current page as a segment in the breadcrumb setting enabled at /admin/config/user-interface/easy-breadcrumb, visit /admin and observe the breadcrumb.
  6. Disable the setting, save, revisit /admin and observe the breadcrumb again.
  7. Confirm the test really covers the configuration: temporarily make the title-segment condition in src/EasyBreadcrumbBuilder.php (line 488) never remove the current page, re-run both the new test and the existing kernel test, then restore the file.

Expected results

  • The new test passes on the current 2.x branch.
  • The new file has no coding standards violations.
  • With the setting enabled, the breadcrumb on /admin renders Home › Administration; with it disabled only Home remains.
  • The new test fails when the title-segment logic in the breadcrumb builder is broken, proving it is not a vacuous test.

Actual results

The test does what it says. On the unmodified 2.x branch it passes: 1 test, 6 assertions. The four reported deprecations are unrelated to this issue — they come from other contrib modules installed on the test site (paragraphs_module_implements_alter without the #[LegacyModuleImplementsAlter] attribute, Drupal\quick_node_clone\EventSubscriber\AddressEventSubscriber::getSubscribedEvents()) and from core/Twig itself. phpcs with the Drupal and DrupalPractice standards reports no violations on the new file. In the browser the asserted behaviour matches: with the setting enabled the breadcrumb on /admin renders as Home › Administration, and with it disabled only the Home segment remains.

The coverage gap the issue describes is real, and the new test closes it. Making the condition at src/EasyBreadcrumbBuilder.php line 488 never pop the current page leaves the whole existing kernel suite green (12 tests, 112 assertions, OK) — the single existing use of INCLUDE_TITLE_SEGMENT in EasyBreadcrumbBuilderTest::testMenuTitleIgnoresFragmentLinks() only sets it as a precondition for a different bug and never asserts the setting's effect. The new functional test does fail under the same change (1 test, 6 assertions, 1 failure, on the "segment is not there" assertion) and passes again once the file is restored.

Scope note: the test covers the /admin path with the default values of the related settings (TITLE_SEGMENT_AS_LINK, TITLE_FROM_PAGE_WHEN_AVAILABLE, ALTERNATIVE_TITLE_FIELD), which is consistent with the scope stated in the issue. Note also that the breadcrumb block is not visible in the Gin admin theme when core's Navigation module is enabled, so the manual verification was done with Claro as the admin theme; this does not affect the test, which runs on Stark.


Testing produced with the assistance of an LLM.

csakiistvan’s picture

Assigned: csakiistvan » Unassigned

  • loopduplicate committed 2809e9f7 on 2.x
    Issue: #3614749 Create test for INCLUDE_TITLE_SEGMENT config.
    
    By:...
loopduplicate’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @csakiistvan

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

csakiistvan’s picture

Welcome @loopduplicate :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.