There currently is no test for the "Use the real page title when available" (TITLE_FROM_PAGE_WHEN_AVAILABLE) 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

Status: Needs review » Needs work

@loopduplicate the test passes, but it does not actually cover TITLE_FROM_PAGE_WHEN_AVAILABLE — details below.

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 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>'

Steps

  1. Apply the fix from MR !201: it adds tests/src/Functional/EasyBreadcrumbTitleFromPageWhenAvailableTest.php, which creates a node aliased /breadcrumb/test and asserts the second breadcrumb segment is Test Page by default and Test once Use the real page title when available is disabled.
  2. Rebuild caches: ddev drush cr
  3. Run the new test and confirm it passes.
  4. Mutation check: temporarily disable both TITLE_FROM_PAGE_WHEN_AVAILABLE branches in src/EasyBreadcrumbBuilder.php (lines 373 and 562) and run the test again.

Expected results

  • The test passes on unmodified 2.x.
  • With both branches disabled, the test fails — otherwise it does not cover the setting.

Actual results

The test passes on unmodified 2.x (1 test, 7 assertions), but it also passes with both TITLE_FROM_PAGE_WHEN_AVAILABLE branches disabled. Dumping the rendered block shows why: in this scenario the breadcrumb is Home / Test Page regardless of the setting. The intermediate /breadcrumb segment is dropped (it is not a valid path), and the last segment comes from the title-segment logic, which falls back to the route title — the node title — so the output never changes. The second assertion only passes because Test is a substring of Test Page; it would pass against the unchanged breadcrumb too. Adding a real node at /breadcrumb does not help either: the intermediate segment renders as Parent Title with the setting both on and off.

A scenario where the setting is observable is the <title> token in Custom paths, which is exactly what the code at line 373 gates. With CUSTOM_PATHS set to /breadcrumb/test :: <title>:

  • TITLE_FROM_PAGE_WHEN_AVAILABLE = TRUEHome / Test Page
  • TITLE_FROM_PAGE_WHEN_AVAILABLE = FALSEHome / (the segment renders empty, the token is not replaced)

Verified locally on unmodified 2.x. Basing the assertions on that scenario would make the test cover the config.


Testing produced with the assistance of an LLM.

loopduplicate’s picture

Assigned: Unassigned » loopduplicate
Status: Needs work » Active

oops, thanks @csakiistvan .

loopduplicate’s picture

Assigned: loopduplicate » Unassigned
Status: Active » Needs review
csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

Assigned: csakiistvan » Unassigned
Status: Needs review » Reviewed & tested by the community

Re-tested after the rework in #6 — the test now covers TITLE_FROM_PAGE_WHEN_AVAILABLE and survives the mutation check.

Environment

  • Drupal: 11.4.4
  • PHP: 8.5.5
  • Database: MariaDB 10.11.16
  • DDEV: v1.25.2
  • Easy Breadcrumb: 2.x (commit 5bfef4e, MR !201)

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>'
  • This is a test-only issue, so there is no user-facing behaviour change. Before the MR, the setting appeared in tests/src/Kernel/EasyBreadcrumbBuilderTest.php only as a precondition of other tests, never as the subject of an assertion.

Steps

  1. Apply the fix from MR !201: it adds tests/src/Functional/EasyBreadcrumbTitleFromPageWhenAvailableTest.php, which places the breadcrumb block, creates a node aliased /breadcrumb, sets Custom paths to /breadcrumb::<title>Test and asserts the second breadcrumb segment with Use the real page title when available disabled and then enabled.
  2. Rebuild caches:
    ddev drush cr
  3. Run the new test:
    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 ../modules/contrib/easy_breadcrumb/tests/src/Functional/EasyBreadcrumbTitleFromPageWhenAvailableTest.php'
  4. Mutation check: temporarily replace the condition of both TITLE_FROM_PAGE_WHEN_AVAILABLE branches in src/EasyBreadcrumbBuilder.php (lines 373 and 562) with FALSE and run the test again.
  5. Restore src/EasyBreadcrumbBuilder.php.

Expected results

  • The test passes on unmodified 2.x.
  • With both branches disabled the test fails, proving the assertions really depend on the setting.

Actual results

Both expectations hold. On unmodified 2.x the test passes (1 test, 7 assertions; the reported deprecations come from the surrounding site, not from the module). With both branches forced to FALSE the test fails at line 68 with The string "Page TitleTest" was not found in the HTML of the element matching css "#block-breadcrumb li:nth-child(2)" — the <title> token is no longer replaced, which is exactly the behaviour gated at line 373. Unlike the previous revision, the two assertions are not in a substring relationship, so neither passes by accident.


Testing produced with the assistance of an LLM.

  • loopduplicate committed b81e0b5d on 2.x
    Issue: #3614982 Create test for TITLE_FROM_PAGE_WHEN_AVAILABLE config...
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 :)

Status: Fixed » Closed (fixed)

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