The configuration option "Applies to administration pages" could use a test.

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 (da98433)
  • Browser: Chrome

Prerequisites

  • Clean Easy Breadcrumb 2.x-dev checkout, no other local modifications.
  • Easy Breadcrumb enabled, admin theme set to Claro so the breadcrumb block is rendered on admin routes:
ddev drush en easy_breadcrumb -y
ddev drush config:set system.theme admin claro -y
ddev drush config:set easy_breadcrumb.settings applies_admin_routes 1 -y
ddev drush cr
  • On the clean checkout, tests/src/Functional/ contains only EasyBreadcrumbConfigureTest.php and EasyBreadcrumbInstallUninstallTest.php, and neither asserts anything about applies_admin_routes — the option is untested.

Steps

  1. Apply the fix from MR !193: adds the functional test EasyBreadcrumbAdminTest covering the "Applies to administration pages" option, and renames/comments EasyBreadcrumbConfigureTest::testAdministration() to testAdministrationAccessAndConfigurationSave() to describe what it actually covers.
  2. Rebuild caches: ddev drush cr
  3. Confirm the covered behaviour manually. With "Applies to administration pages" enabled, visit /admin as an administrator and note the breadcrumb reads Home / Administration.
  4. Go to /admin/config/user-interface/easy-breadcrumb, untick Applies to administration pages, save, then reload /admin and note the breadcrumb is only Home.
  5. Run both functional tests:
ddev exec -d /var/www/html "vendor/bin/phpunit -c web/core/phpunit.xml.dist \
  web/modules/contrib/easy_breadcrumb/tests/src/Functional/EasyBreadcrumbAdminTest.php \
  web/modules/contrib/easy_breadcrumb/tests/src/Functional/EasyBreadcrumbConfigureTest.php"
  1. Verify the new test actually guards the behaviour: temporarily replace the admin-route condition in EasyBreadcrumbBuilder::applies() with if (FALSE) { so the option is ignored, re-run EasyBreadcrumbAdminTest, then revert the change.
  2. Run the coding standards check:
ddev exec -d /var/www/html "vendor/bin/phpcs --standard=Drupal,DrupalPractice \
  web/modules/contrib/easy_breadcrumb/tests/src/Functional/EasyBreadcrumbAdminTest.php \
  web/modules/contrib/easy_breadcrumb/tests/src/Functional/EasyBreadcrumbConfigureTest.php"

Expected results

  • The manual check confirms the behaviour under test: the second breadcrumb Administration appears on /admin when the option is on, and disappears when it is off.
  • Both functional tests pass with the MR applied.
  • With the admin-route condition disabled, EasyBreadcrumbAdminTest fails — proving the new test genuinely covers the option rather than passing unconditionally.
  • No coding standards violations in either test file.

Actual results

Before the MR the "Applies to administration pages" option had no automated coverage at all, so a regression in EasyBreadcrumbBuilder::applies() would have gone unnoticed. The manual browser check on 2.x-dev matched the expectation: with the option enabled the breadcrumb on /admin read Home / Administration, and with it disabled only Home remained. With MR !193 applied both functional tests passed (2 tests, 15 assertions; the 4 reported deprecations come from Drupal core and unrelated contrib code in this site, not from the MR). Replacing the admin-route condition with if (FALSE) made EasyBreadcrumbAdminTest::testAppliesAdminRoutes fail as expected on the "option off" assertion, confirming the test is effective; reverting restored a green run. phpcs against Drupal,DrupalPractice reported no violations for either file.


Testing produced with the assistance of an LLM.

  • loopduplicate committed 070d5348 on 2.x
    Issue: #3614585 Create test for "Applies to administration pages"
    
    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.

csakiistvan’s picture

Welcome @loopduplicate :)

Status: Fixed » Closed (fixed)

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