There currently is no test for the "Add parent hierarchy" (TERM_HIERARCHY) 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

✅ Tested and works — MR !218.

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 TERM_HIERARCHY web/modules/contrib/easy_breadcrumb/tests/ returns no matches.
Steps
  1. Apply the fix from MR !218: it adds tests/src/Functional/EasyBreadcrumbTermHierarchyTest.php, a functional test that builds a three-level taxonomy hierarchy (ParentChildGrandchild), enables Add parent hierarchy, visits the grandchild term page and asserts the three breadcrumb segments in order.
  2. Rebuild caches: ddev drush cr
  3. Run the new test and confirm it passes.
  4. Mutation check: temporarily replace the TERM_HIERARCHY condition in src/EasyBreadcrumbBuilder.php (line 676) with FALSE so parents are never added, 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 the parent-hierarchy branch 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 TERM_HIERARCHY, so the "Add parent hierarchy" setting was completely uncovered. After applying MR !218 the new test ran green (1 test, 4 assertions; only pre-existing unrelated deprecation notices). With the condition forced to FALSE it failed with Behat\Mink\Exception\ElementHtmlException: The string "Parent" was not found in the HTML of the element matching css "#block-breadcrumb li:nth-child(2)", confirming the assertions are meaningful; asserting all three segments by position also pins the parent order rather than just their presence. 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 committed c69a9be6 on 2.x
    Issue: #3616162 Create test for TERM_HIERARCHY config Primary tabs View...
loopduplicate’s picture

Status: Reviewed & tested by the community » Fixed

thanks @csakiistva

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 :)