There currently is no test for the "Remove repeated identical segments" (REMOVE_REPEATED_SEGMENTS) 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 !197)
  • Browser: Chrome

Prerequisites

  • Enable the module:
    ddev drush en easy_breadcrumb -y
  • Use a theme that renders the breadcrumb block (Olivero was used for the manual check).
  • Three nodes are needed so that both repeated-segment modes can be told apart — two of the repeated segments must be real paths:
    /test
    /test/test
    /test/test/repeated/repeated/repeated/segments/segments/test-page
  • 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 !197: it adds the functional test tests/src/Functional/EasyBreadcrumbRemoveRepeatedSegmentsTest.php, which places the breadcrumb block, creates the three aliased nodes, and asserts every breadcrumb segment on the deep path for three configuration states: Remove repeated identical segments off, on, and on together with Remove repeated segments based on text only.
  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/EasyBreadcrumbRemoveRepeatedSegmentsTest.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/EasyBreadcrumbRemoveRepeatedSegmentsTest.php'
  5. Verify the same behaviour manually: at /admin/config/user-interface/easy-breadcrumb disable Remove repeated identical segments, enable Include invalid paths as plain-text segments, then visit /test/test/repeated/repeated/repeated/segments/segments/test-page and observe the breadcrumb.
  6. Enable Remove repeated identical segments, revisit the page and observe the breadcrumb again.
  7. Additionally enable Remove repeated segments based on text only, revisit the page and observe the breadcrumb a third time.
  8. Confirm the test really covers the configuration: temporarily invert the REMOVE_REPEATED_SEGMENTS condition in src/EasyBreadcrumbBuilder.php and re-run the test, then restore the file.

Expected results

  • The new test passes on the current 2.x branch.
  • The new file has no coding standards violations.
  • The breadcrumb collapses step by step in the browser: all repeats kept with the setting off, only segments that are not real paths collapsed with it on, and all textual repeats collapsed with the text-only option added.
  • The test fails when the repeated-segment logic in the breadcrumb builder is broken, proving it is not a vacuous test.

Actual results

Before the change nothing in tests/ referenced REMOVE_REPEATED_SEGMENTS, so the configuration was completely uncovered. The new test does what it says: on the unmodified 2.x branch it passes with 1 test and 25 assertions, and phpcs with the Drupal and DrupalPractice standards reports no violations on the new file. In the browser the asserted behaviour matches. On the deep path the breadcrumb renders as Test Page › Test Page › Repeated › Repeated › Repeated › Segments › Segments › Test Page with Remove repeated identical segments disabled, as Test Page › Test Page › Repeated › Segments › Test Page with it enabled (the second segment survives because /test/test is a real path), and as Test Page › Repeated › Segments › Test Page once Remove repeated segments based on text only is also enabled. The test is genuinely sensitive to the configuration: inverting the REMOVE_REPEATED_SEGMENTS condition in src/EasyBreadcrumbBuilder.php (line 720) makes it fail in the second configuration block (1 failure, 10 assertions), and it passes again once the file is restored.

Two minor, non-blocking notes. The test run triggers a core deprecation that points at the new file: functional test classes must declare the #[RunTestsInSeparateProcesses] attribute since Drupal 11.3, and none of the module's functional tests do — worth adding here, or in a follow-up covering the whole test suite. The remaining deprecations are unrelated to this issue and 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. The manual verification used articles instead of the page content type created by the test, which does not affect the outcome.


Testing produced with the assistance of an LLM.

  • loopduplicate committed ed1a6859 on 2.x
    Issue: #3614754 Create test for REMOVE_REPEATED_SEGMENTS 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.