Tests: Add trait AdminToolbarHelperTestTrait

Created on 1 October 2025, 7 days ago

Problem/Motivation

The module currently does not have a common method for test classes to check whether a specific link exists or not in the admin toolbar.

Each class currently has its own "copy" of the same methods/code: protected function assertMenuHasHref($url)

The same goes for assertMenuDoesNotHaveHref.

The methods are all marked as protected, so they could not be called from a separate test class, requiring another set of methods to be implemented for the test, which is nor practical or sustainable in terms of maintenance.

Proposed resolution

Add the new trait AdminToolbarHelperTestTrait to provide a common method for module's test classes to check that a specific link exists or not in the admin toolbar.

The trait could then be used by any test class whether Functional or FunctionalJavascript and provide a standard method for asserting a link exists in the admin toolbar.

Additionally, we could improve the method of asserting a link exists by adding more specific conditions, such as the link text, display position (order) or CSS classes.

Replace current implementations in \Drupal\Tests\admin_toolbar\Functional\AdminToolbarToolsSortTest by using the trait's method.

📌 Task
Status

Needs review

Version

3.0

Component

Automated tests

Created by

🇫🇷France dydave

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024