There currently is no test for the "Include invalid paths alias as plain-text segments" (INCLUDE_INVALID_PATHS) 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-dev (c68c5f0, MR !195)
  • Browser: Chrome

Prerequisites

  • Enable the module:
    ddev drush en easy_breadcrumb -y
  • Keep the module defaults for the related settings, so both the home and the title segment are rendered:
    ddev drush config:set easy_breadcrumb.settings include_home_segment true -y
    ddev drush config:set easy_breadcrumb.settings include_title_segment true -y
  • Create a published node whose URL alias has path segments that do not resolve to any route, so the invalid-path handling is exercised:
    ddev drush php:eval '$n = \Drupal\node\Entity\Node::create(["type" => "article", "title" => "Test Page 1", "status" => 1, "path" => ["alias" => "/invalid/parent/paths"]]); $n->save();'

    Pick alias segments that are unused on the site — if a segment such as /test happens to be a valid path, it is rendered as a link by the valid-path branch instead.

  • This is a test-only issue, so there is no user-facing behaviour change. The behaviour asserted by the new test was verified manually in the browser as well.

Steps

  1. Apply the fix from MR !195: it adds the functional test tests/src/Functional/EasyBreadcrumbIncludeInvalidPathsTest.php, which places the breadcrumb block, creates a node with the alias /test/invalid/paths, enables the Include invalid paths alias as plain-text segments setting and asserts each of the four breadcrumb segments.
  2. Rebuild caches:
    ddev drush cr
  3. 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/EasyBreadcrumbIncludeInvalidPathsTest.php'
  4. Check the coding standards of the new file:
    ddev exec 'cd /var/www/html && vendor/bin/phpcs --standard=Drupal,DrupalPractice web/modules/contrib/easy_breadcrumb/tests/src/Functional/EasyBreadcrumbIncludeInvalidPathsTest.php'
  5. Verify the same behaviour manually: with the Include invalid paths alias as plain-text segments setting disabled at /admin/config/user-interface/easy-breadcrumb, visit /invalid/parent/paths and observe the breadcrumb.
  6. Enable the setting, save, revisit /invalid/parent/paths and observe the breadcrumb again.
  7. Confirm the test really covers the configuration: temporarily make the invalid-path condition in src/EasyBreadcrumbBuilder.php (line 691) never add a segment, re-run both the new test and the pre-existing test suite, then restore the file.

Expected results

  • The new test passes on the current 2.x branch.
  • The new file has no coding standards violations.
  • With the setting disabled, the breadcrumb on /invalid/parent/paths renders Home › Test Page 1; with it enabled the invalid segments appear as plain text: Home › Invalid › Parent › Test Page 1.
  • The new test fails when the invalid-path logic in the breadcrumb builder is broken, proving it is not a vacuous test.

Actual results

The test does what it says. On the unmodified 2.x branch it passes: 1 test, 6 assertions. The four reported deprecations are unrelated to this issue — they come from other contrib modules installed on the test site (paragraphs_module_implements_alter without the #[LegacyModuleImplementsAlter] attribute, Drupal\quick_node_clone\EventSubscriber\AddressEventSubscriber::getSubscribedEvents()) and from core/Twig itself. phpcs with the Drupal and DrupalPractice standards reports no violations on the new file. In the browser the asserted behaviour matches: with the setting disabled the breadcrumb renders as Home › Test Page 1, and with it enabled the two invalid parent segments are rendered as plain text, Home › Invalid › Parent › Test Page 1 — capitalised and with the current page still last.

The coverage gap the issue describes is real, and the new test closes it. Before the MR, INCLUDE_INVALID_PATHS appeared only in easy_breadcrumb.install, src/EasyBreadcrumbConstants.php, src/Form/EasyBreadcrumbGeneralSettingsForm.php and src/EasyBreadcrumbBuilder.php — no test referenced it. Making the condition at src/EasyBreadcrumbBuilder.php line 691 never fire leaves the whole pre-existing suite green (14 tests, 132 assertions, OK). The new functional test does fail under the same change (1 test, 5 assertions, 1 failure, on the second breadcrumb segment) and passes again once the file is restored.

Scope note: the test relies on the alias /test/invalid/paths having no valid parent paths, which holds on a freshly installed test site but not necessarily on an existing one — on the manual verification site /test was an existing alias, so a different alias was used for the browser check. This does not affect the test itself, which runs on a clean Stark install. The test covers the default values of the related settings, which is consistent with the scope stated in the issue.


Testing produced with the assistance of an LLM.

  • loopduplicate committed 5bfef4e6 on 2.x
    Issue: #3614715 Create test for INCLUDE_INVALID_PATHS config
    
    By:...
loopduplicate’s picture

Status: Reviewed & tested by the community » Fixed

Thank you @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.