There currently is no test for the "Add current breadcrumb as structured data" (ADD_STRUCTURED_DATA_JSON_LD) 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

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 (2.x, commit c68c5f0)

Prerequisites

  • Easy Breadcrumb checked out on the 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 ADD_STRUCTURED_DATA_JSON_LD web/modules/contrib/easy_breadcrumb/tests/ returns no matches.

Steps

  1. Apply the fix from MR !205: it adds tests/src/Functional/EasyBreadcrumbAddJsonLdTest.php, a functional test that asserts no application/ld+json element is present in the head with Add current breadcrumb as structured data disabled, and that a BreadcrumbList element appears once the setting is enabled.
  2. Rebuild caches: ddev drush cr
  3. Run the new test and confirm it passes.
  4. Mutation check: temporarily disable the JSON-LD branch in src/EasyBreadcrumbStructuredDataJsonLd.php (around line 85) so the markup is never built, and run the test again.
  5. Revert the change to EasyBreadcrumbStructuredDataJsonLd.php and run the test a final time.

Expected results

  • The new test passes on unmodified 2.x.
  • With the JSON-LD branch disabled, the test fails — proving it genuinely covers the setting rather than passing vacuously.
  • After reverting, the test passes again.

Actual results

Before the fix no test referenced ADD_STRUCTURED_DATA_JSON_LD, so the "Add current breadcrumb as structured data" setting was completely uncovered. After applying MR !205 the new test ran green (1 test, 5 assertions; only pre-existing unrelated deprecation notices). Disabling the JSON-LD branch made it fail with Behat\Mink\Exception\ElementNotFoundException: Element matching css "head script[type="application/ld+json"]" not found., confirming the assertions are meaningful. Reverting the service restored a green run.


Testing produced with the assistance of an LLM.

csakiistvan’s picture

Assigned: csakiistvan » Unassigned

  • loopduplicate committed 41a92adb on 2.x
    Issue: #3615292 Create test for ADD_STRUCTURED_DATA_JSON_LD config
    
    By:...
loopduplicate’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @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.