There currently is no test for the "Make the language path prefix a segment" (LANGUAGE_PATH_PREFIX_AS_SEGMENT) 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

✅ Tested and works — MR !215.

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 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>'
  • Confirm the coverage gap before the fix: grep -rn LANGUAGE_PATH_PREFIX_AS_SEGMENT web/modules/contrib/easy_breadcrumb/tests/ returns no matches.
Steps
  1. Apply the fix from MR !215: it adds tests/src/Functional/EasyBreadcrumbLanguagePathPrefixAsSegmentTest.php, which adds a Hungarian language, creates a translated node aliased /test-page, and checks the hu prefix on /hu/test-page — absent by default, still absent with Include invalid paths alone, and present once Make the language path prefix a segment is enabled.
  2. Rebuild caches: ddev drush cr
  3. Run the new test and confirm it passes.
  4. Mutation check 1: temporarily replace the condition in src/EasyBreadcrumbBuilder.php (line 495) with TRUE, so the prefix is always stripped, and run the test again.
  5. Mutation check 2: replace it with FALSE, so the prefix is never stripped, and run the test again.
  6. Revert src/EasyBreadcrumbBuilder.php and run the test a final time.
Expected results
  • The new test passes on unmodified 2.x.
  • Both mutations fail — one for each direction of the setting.
  • After reverting, the test passes again.
Actual results

Before the fix no test referenced LANGUAGE_PATH_PREFIX_AS_SEGMENT, so the setting was completely uncovered. After applying MR !215 the new test ran green (1 test, 8 assertions; only pre-existing unrelated deprecation notices). Both mutations are caught: with the condition forced to TRUE the test fails with The string "Hu" was not found in the HTML of the element matching css "#block-breadcrumb li:nth-child(2)", and with FALSE it fails with The string "Hu" appears in the HTML of the element matching css "#block-breadcrumb li:nth-child(2)", but it should not. — so both the enabled and the disabled behaviour are pinned. The extra step with Include invalid paths is a good guard, since that option is the obvious way an unintended language segment could sneak back in. Reverting the builder restored a green run. phpcs --standard=Drupal,DrupalPractice reports no issues on the test file.


Testing produced with the assistance of an LLM.

loopduplicate’s picture

Status: Reviewed & tested by the community » Needs review

Marking this as needs review per comments in the MR. A change was made to allow to showing the language segment without allowing invalid paths.

greg boggs’s picture

Status: Needs review » Reviewed & tested by the community

It's not just a test add: the Aug 14 update also changes the source so the language-prefix segment can show on its own, without needing INCLUDE_INVALID_PATHS enabled too.

Ran the full suite with the MR applied: 38/38 pass. Then reverted just the source change and kept the test: it failed, showing "Test Page" instead of "Hu." So the source fix is actually needed, not dead code.

AI was used in assisting to test this issue

loopduplicate’s picture

Assigned: Unassigned » loopduplicate

  • loopduplicate committed f1a13e83 on 2.x
    task: #3615998 Create test for LANGUAGE_PATH_PREFIX_AS_SEGMENT config...
loopduplicate’s picture

Assigned: loopduplicate » Unassigned
Status: Reviewed & tested by the community » Fixed

Thank you @greg boggs and @csakiistvan :3

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.

Status: Fixed » Closed (fixed)

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