There currently is no test for the "Display the front page segment on the front page" (HOME_SEGMENT_KEEP) 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

Assigned: csakiistvan » Unassigned
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 (2.x, commit c68c5f0)

Prerequisites

  • Easy Breadcrumb checked out on the 2.x branch inside a Drupal 11.4.4 site.
  • PHPUnit runnable against the site, e.g.:
    ddev exec 'cd web/core && SIMPLETEST_BASE_URL=http://web SIMPLETEST_DB=mysql://db:db@db/db BROWSERTEST_OUTPUT_DIRECTORY=/tmp ../../vendor/bin/phpunit -c phpunit.xml.dist <test-path>'
  • Confirm the coverage gap before the fix: grep -rn HOME_SEGMENT_KEEP web/modules/contrib/easy_breadcrumb/tests/ returns no matches.

Steps

  1. Apply the fix from MR !210: it adds tests/src/Functional/EasyBreadcrumbHomeSegmentKeepTest.php, a functional test that sets a node as the front page, enables the Display the front page segment on the front page setting, and asserts the second breadcrumb item on the front page contains the page title.
  2. Rebuild caches: ddev drush cr
  3. Run the new test and confirm it passes.
  4. Mutation check: temporarily force $keep_front to FALSE in src/EasyBreadcrumbBuilder.php (around line 310) and run the test again.
  5. Revert the change to EasyBreadcrumbBuilder.php and run the test a final time.

Expected results

  • The new test passes on unmodified 2.x.
  • With the HOME_SEGMENT_KEEP branch disabled, the test fails — proving it genuinely covers the setting rather than passing vacuously.
  • After reverting, the test passes again.
  • The pre-existing suite (e.g. EasyBreadcrumbInstallUninstallTest) is unaffected.

Actual results

Before the fix no test referenced HOME_SEGMENT_KEEP, so the "Display the front page segment on the front page" setting was completely uncovered. After applying MR !210 the new test ran green (1 test, 3 assertions; only pre-existing unrelated deprecation notices). Forcing $keep_front = FALSE made it fail with Behat\Mink\Exception\ElementNotFoundException: Element matching css "#block-breadcrumb li:nth-child(2)" not found., confirming the assertion is meaningful. Reverting the builder restored a green run. EasyBreadcrumbInstallUninstallTest also stayed green (1 test, 11 assertions).


Testing produced with the assistance of an LLM.

  • loopduplicate committed e1cd84bd on 2.x
    Issue: #3615355 Create test for HOME_SEGMENT_KEEP 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 :)

greg boggs’s picture

All your work on the module has been amazing. There's a few features that I accidentally broke in the module that currently need work. One of the things that is broken is this feature.

With this feature turned off, there should be no breadcrumb on the front page.

With this featured turned on, there should be a Home page breadcrumb with the text "Home" because that's part of the default configuration.

I believe the ideal test for this feature is:

    // Tests that first breadcrumb is the page title.
    $this->assertSession()->elementContains(
      'css',
      '#block-breadcrumb li:nth-child(1)',
      'Home',
    );
greg boggs’s picture

Here's the issue the previous maintainer created for the issue. His plan was to reverse the feature, so that it's turned on by default and turning it on hides the homepage crumb on the homepage. I don't have opinions on rewording the feature, but it would be nice to get this working again.

https://www.drupal.org/project/easy_breadcrumb/issues/3460611

loopduplicate’s picture

Whoops! Thanks for catching this, Greg. I made a follow up: #3616195

loopduplicate’s picture

Closed that follow up issue I created in favor of using the old one, https://www.drupal.org/project/easy_breadcrumb/issues/3460611

Status: Fixed » Closed (fixed)

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