There currently is no test for the "Truncate the page's title to a maximum number" (TRUNCATOR_MODE) 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 (commit 5bfef4e)

Prerequisites

  • Easy Breadcrumb checked out on a clean 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 TRUNCATOR_MODE web/modules/contrib/easy_breadcrumb/tests/ returns no matches.

Steps

  1. Apply the fix from MR !220: it adds tests/src/Functional/EasyBreadcrumbTruncatorModeTest.php, a functional test that creates a node titled Page With Long Title, enables Truncate the page's title to a maximum number with a length of 8, and asserts the segment reads Page ..., then Page Wit after disabling the trailing dots.
  2. Rebuild caches: ddev drush cr
  3. Run the new test and confirm it passes.
  4. Mutation check: temporarily replace both TRUNCATOR_MODE conditions in src/EasyBreadcrumbBuilder.php (lines 586 and 656) with FALSE so truncation never happens, and run the test again.
  5. Revert src/EasyBreadcrumbBuilder.php and run the test a final time.

Expected results

  • The new test passes on unmodified 2.x.
  • With truncation 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 TRUNCATOR_MODE, so the "Truncate the page's title to a maximum number" setting was completely uncovered. After applying MR !220 the new test ran green (1 test, 8 assertions; only pre-existing unrelated deprecation notices). With both truncation conditions forced to FALSE it failed with Behat\Mink\Exception\ElementHtmlException: The string "Page ..." was not found in the HTML of the element matching css "#block-breadcrumb li:nth-child(2)", confirming the assertions are meaningful; the closing elementNotContains on the full title also guards against the untruncated value. Reverting the builder restored a green run. phpcs --standard=Drupal,DrupalPractice reports no issues on the test file.


Testing produced with the assistance of an LLM.

loopduplicate’s picture

Status: Reviewed & tested by the community » Needs review

lol, @csakiistvan. Wrong issue! Do I need to search the flag issue queue to find the review for this? Just kidding :3

csakiistvan’s picture

Sorry sorry sorry @loopduplicate, previous comment updated 🙈

loopduplicate’s picture

Status: Needs review » Reviewed & tested by the community

thanks :3 will get it merged in soon

  • loopduplicate committed e51259aa on 2.x
    Issue: #3616187 Create test for TRUNCATOR_MODE config
    
    By: loopduplicate...
greg boggs’s picture

Looks perfect.

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.

loopduplicate’s picture

nice, thanks @greg for reviewing too. I updated the contrib record.

Status: Fixed » Closed (fixed)

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