There currently is no test for the "Alternative title field name for breadcrumb" (ALTERNATIVE_TITLE_FIELD) 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

Environment

  • Drupal: 11.4.4
  • PHP: 8.5.5
  • Database: MariaDB 10.11.16
  • DDEV: v1.25.2
  • Easy Breadcrumb: 2.x-dev (c68c5f0)
  • Browser: Chrome

Prerequisites

  • Easy Breadcrumb enabled and the breadcrumb block placed in the front-end theme (Olivero ships one by default):
    ddev drush en easy_breadcrumb -y
  • A plain text (string) field named field_breadcrumb_title on a content type, and a published node of that type with an URL alias and the field populated.
  • The general settings at /admin/config/user-interface/easy-breadcrumb with Include the current page title in the breadcrumb enabled (default).

Steps

  1. Apply the test from MR !199: it adds tests/src/Functional/EasyBreadcrumbAlternateTitleFieldTest.php, a functional test that populates an alternative title field, sets the alternative_title_field setting, and asserts the breadcrumb's last segment before and after clearing that setting.
  2. Rebuild caches:
    ddev drush cr
  3. Verify the behaviour under test manually: set Alternative title field name for breadcrumb to field_breadcrumb_title at /admin/config/user-interface/easy-breadcrumb, save, then visit the node's alias and read the last breadcrumb segment.
  4. Clear Alternative title field name for breadcrumb, save, reload the node page and read the last breadcrumb segment again.
  5. Run the new test:
    ddev exec 'cd /var/www/html/web && ../vendor/bin/phpunit -c core/phpunit.xml.dist modules/contrib/easy_breadcrumb/tests/src/Functional/EasyBreadcrumbAlternateTitleFieldTest.php'
  6. Run the whole module suite plus coding standards to confirm nothing else regressed:
    ddev exec 'cd /var/www/html/web && ../vendor/bin/phpunit -c core/phpunit.xml.dist modules/contrib/easy_breadcrumb/tests/src/Functional/ modules/contrib/easy_breadcrumb/tests/src/Kernel/'
    ddev exec 'cd /var/www/html && vendor/bin/phpcs --standard=Drupal,DrupalPractice web/modules/contrib/easy_breadcrumb/tests/src/Functional/EasyBreadcrumbAlternateTitleFieldTest.php'
  7. Confirm the test really guards the feature: temporarily short-circuit the alternative title field branch in src/TitleResolver.php::getTitle(), re-run the test, then revert the change.

Expected results

  • With the setting populated, the last breadcrumb segment shows the alternative field value instead of the node title.
  • With the setting empty, the last breadcrumb segment falls back to the node title.
  • The new functional test passes.
  • The full module test suite passes and the new file is clean against Drupal and DrupalPractice.
  • The new test fails when the alternative title field logic is disabled, proving it covers the configuration rather than passing vacuously.

Actual results

Before the MR, ALTERNATIVE_TITLE_FIELD had no coverage for a populated value — the only other reference in the test suite sets it to an empty string in tests/src/Kernel/EasyBreadcrumbBuilderTest.php. Manual verification in the browser matched the assertions: with field_breadcrumb_title configured the breadcrumb read Home > Test Breadcrumb Alternate Title Field, and after clearing the setting it read Home > Test Page. With the MR applied, EasyBreadcrumbAlternateTitleFieldTest passed (1 test, 7 assertions) and the full functional plus kernel suites passed (15 tests, 139 assertions); the reported deprecations originate from unrelated contrib modules installed in the test site, not from this module. phpcs reported no violations on the new file. Short-circuiting the alternative title field branch in TitleResolver::getTitle() made the new test fail as expected, confirming it genuinely covers the configuration.


Testing produced with the assistance of an LLM.

csakiistvan’s picture

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

  • loopduplicate committed 5666eb50 on 2.x
    Issue: #3614877 Create test for ALTERNATIVE_TITLE_FIELD config
    
    By:...
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.