There currently is no test for the "Do not check for path, that is duplicate of home page." (HOME_SEGMENT_VALIDATION_SKIP) 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.

tribekk made their first commit to this issue’s fork.

tribekk’s picture

Status: Active » Needs review

Opened MR !211.

Adds a functional test for a breadcrumb path with an intermediate segment that resolves to the configured front page. It covers both the default behavior and HOME_SEGMENT_VALIDATION_SKIP enabled.

Checked locally:
- php -l tests/src/Functional/EasyBreadcrumbHomeSegmentValidationSkipTest.php
- composer validate --no-check-publish
- git diff --check

csakiistvan made their first commit to this issue’s fork.

csakiistvan’s picture

@tribekk the test needed two small fixes — the pipeline failure is reproducible locally and is caused by the test itself, not by the module. I pushed them to the MR branch; details below.

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_VALIDATION_SKIP web/modules/contrib/easy_breadcrumb/tests/ returns no matches.

Steps

  1. Apply the fix from MR !211: it adds tests/src/Functional/EasyBreadcrumbHomeSegmentValidationSkipTest.php, a functional test that makes a node aliased /front-page the site front page, adds a child node aliased /front-page/child-page, and asserts the intermediate segment is dropped by default but kept once Do not check for path, that is duplicate of home page is enabled.
  2. Rebuild caches: ddev drush cr
  3. Run the new test and confirm it passes.
  4. Mutation check: temporarily disable the HOME_SEGMENT_VALIDATION_SKIP branch in src/EasyBreadcrumbBuilder.php (around line 1004) 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_VALIDATION_SKIP branch disabled, the test fails — proving it genuinely covers the setting.
  • After reverting, the test passes again.

Actual results

The MR as committed fails, both in the phpunit CI job and locally: Behat\Mink\Exception\ElementHtmlException: The string "Child page" was not found in the HTML of the element matching css "#block-breadcrumb li:nth-child(2)". Two problems in the test:

  • system.site page.front is set to $front_page->toUrl()->getInternalPath(), which returns node/1 without the leading slash. Drupal stores this setting with a leading slash, and EasyBreadcrumbBuilder compares the processed path against it, so the front-page exclusion never matches. With the raw value the breadcrumb is identical (Home / Front Page / Child Page) whether the setting is on or off, so the test could not cover the config at all. Using '/' . $front_page->toUrl()->getInternalPath() produces the intended difference: Home / Child Page by default, Home / Front Page / Child Page with the setting enabled.
  • The asserted strings do not match the rendered output. Easy Breadcrumb capitalises segment titles, so the breadcrumb reads Front Page and Child Page, while the test asserts Front page / Child page.

With those two changes applied locally, the test passes on unmodified 2.x (1 test, 5 assertions; only pre-existing unrelated deprecation notices), and fails with ElementHtmlException: The string "Front Page" was not found ... once the HOME_SEGMENT_VALIDATION_SKIP branch is disabled — so the scenario itself is right and covers the config. phpcs --standard=Drupal,DrupalPractice reports no issues on the test file.


Testing produced with the assistance of an LLM.

loopduplicate’s picture

Assigned: loopduplicate » Unassigned
Status: Needs review » Closed (won't fix)
Issue tags: -Needs test

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.

loopduplicate’s picture

Assigned: Unassigned » loopduplicate
Status: Closed (won't fix) » Active

loopduplicate’s picture

Assigned: loopduplicate » Unassigned
Status: Active » Fixed

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.

Status: Fixed » Closed (fixed)

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