There currently is no test for the "Titles to be replaced while generating segments" (REPLACED_TITLES) 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 REPLACED_TITLES web/modules/contrib/easy_breadcrumb/tests/ returns no matches.

Steps

  1. Apply the fix from MR !209: it adds tests/src/Functional/EasyBreadcrumbReplacedTitlesTest.php, a functional test that creates a node with the path alias /test, sets the Titles to be replaced while generating segments config to Test::Replaced, and asserts the second breadcrumb item on that page contains Replaced.
  2. Rebuild caches: ddev drush cr
  3. Run the new test and confirm it passes.
  4. Mutation check: temporarily force $mapValues to an empty array in src/EasyBreadcrumbBuilder.php (around line 281) so the replacement map is never built, 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 title replacement map disabled, the test fails — proving it genuinely covers the setting rather than passing vacuously.
  • After reverting, the test passes again.

Actual results

Before the fix no test referenced REPLACED_TITLES, so the "Titles to be replaced while generating segments" setting was completely uncovered. After applying MR !209 the new test ran green (1 test, 6 assertions; only pre-existing unrelated deprecation notices). Emptying the replacement map made it fail with Behat\Mink\Exception\ElementHtmlException: The string "Replaced" was not found in the HTML of the element matching css "#block-breadcrumb li:nth-child(2)"., confirming the assertion is meaningful. Reverting the builder restored a green run.


Testing produced with the assistance of an LLM.

loopduplicate’s picture

Status: Reviewed & tested by the community » Fixed

Thank you @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.