There currently is no test for the "Use the real page title when available" (TITLE_FROM_PAGE_WHEN_AVAILABLE) config.
Issue fork easy_breadcrumb-3614982
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
Comment #3
loopduplicate commentedComment #4
csakiistvan@loopduplicate the test passes, but it does not actually cover
TITLE_FROM_PAGE_WHEN_AVAILABLE— details below.Environment
Prerequisites
2.xbranch inside a Drupal 11.4.4 site.Steps
tests/src/Functional/EasyBreadcrumbTitleFromPageWhenAvailableTest.php, which creates a node aliased/breadcrumb/testand asserts the second breadcrumb segment is Test Page by default and Test once Use the real page title when available is disabled.ddev drush crTITLE_FROM_PAGE_WHEN_AVAILABLEbranches insrc/EasyBreadcrumbBuilder.php(lines 373 and 562) and run the test again.Expected results
2.x.Actual results
The test passes on unmodified
2.x(1 test, 7 assertions), but it also passes with bothTITLE_FROM_PAGE_WHEN_AVAILABLEbranches disabled. Dumping the rendered block shows why: in this scenario the breadcrumb is Home / Test Page regardless of the setting. The intermediate/breadcrumbsegment 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 becauseTestis a substring ofTest Page; it would pass against the unchanged breadcrumb too. Adding a real node at/breadcrumbdoes 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. WithCUSTOM_PATHSset to/breadcrumb/test :: <title>:TITLE_FROM_PAGE_WHEN_AVAILABLE = TRUE→ Home / Test PageTITLE_FROM_PAGE_WHEN_AVAILABLE = FALSE→ Home / (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.
Comment #5
loopduplicate commentedoops, thanks @csakiistvan .
Comment #6
loopduplicate commentedComment #7
csakiistvanComment #8
csakiistvanRe-tested after the rework in #6 — the test now covers
TITLE_FROM_PAGE_WHEN_AVAILABLEand survives the mutation check.Environment
5bfef4e, MR !201)Prerequisites
2.xbranch inside a Drupal 11.4.4 site.tests/src/Kernel/EasyBreadcrumbBuilderTest.phponly as a precondition of other tests, never as the subject of an assertion.Steps
tests/src/Functional/EasyBreadcrumbTitleFromPageWhenAvailableTest.php, which places the breadcrumb block, creates a node aliased/breadcrumb, sets Custom paths to/breadcrumb::<title>Testand asserts the second breadcrumb segment with Use the real page title when available disabled and then enabled.TITLE_FROM_PAGE_WHEN_AVAILABLEbranches insrc/EasyBreadcrumbBuilder.php(lines 373 and 562) withFALSEand run the test again.src/EasyBreadcrumbBuilder.php.Expected results
2.x.Actual results
Both expectations hold. On unmodified
2.xthe test passes (1 test, 7 assertions; the reported deprecations come from the surrounding site, not from the module). With both branches forced toFALSEthe 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.
Comment #10
loopduplicate commentedThanks @csakiistvan
Comment #12
csakiistvanWelcome @loopduplicate :)