PHPUnit: Improve Tests coverage for admin_toolbar_tools menu links and 'ToolbarController' class

Created on 22 March 2025, about 2 months ago

Problem/Motivation

Currently tests coverage is very limited for the admin_toolbar_tools module, see:
https://git.drupalcode.org/project/admin_toolbar/-/tree/3.x/admin_toolba...

None of the links or routes of the module are being tested, see all routes:
https://git.drupalcode.org/project/admin_toolbar/-/blob/3.x/admin_toolba...

Currently, the module doesn't test any of links, routes defined by the admin_toolbar_tools module and the corresponding ToolbarController methods, see:
https://git.drupalcode.org/project/admin_toolbar/-/blob/3.x/admin_toolba...

Steps to reproduce

Run PHPUNIT Tests for the admin_toolbar_tools module.

Proposed resolution

Create a new Functional Tests class AdminToolbarToolsToolbarControllerTest which adds very basic Tests coverage:
For each route/link added by the module, try clicking on it and check whether the correct status message is displayed.
 

Any help, comments, suggestions or feedback would be greatly appreciated.
Thanks!

📌 Task
Status

Active

Version

3.0

Component

Code

Created by

🇫🇷France dydave

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

Merge Requests

Comments & Activities

  • Issue created by @dydave
    • dydave committed 33c5297b on 3.x
      Issue #3514774 by dydave: Added basic PHPUNIT Tests coverage for '...
  • 🇫🇷France dydave

    Quick follow-up on this issue:

    Added very basic Functional Tests coverage for the ToolbarController class with the new class AdminToolbarToolsToolbarControllerTest:
    At least with these Tests, all the methods and code in the ToolbarController class will be executed, which should allow us to detect deprecation messages, various errors, crashes, breaking changes in merge requests, etc...

    The tests don't actually check whether each action effectively "worked", in the sense:
    Each task is not tested specifically, for example, there is are no specific checks on caches, registries, etc...
    But instead, the Tests execute each method's code from the ToolbarController class and check it completed without error (display the expected success message).

    Automated tests all seemed to be passing 🟢, therefore, I went ahead and merged the changes above at #3.

    With these tests in place, there should be at least some very basic Functional validation for all the pending merge requests making changes to the ToolbarController class, see in particular related tickets.

    Important note: Fixed a minor error in the file admin_toolbar.libraries.yml, recently introduced in commit:
    https://git.drupalcode.org/project/admin_toolbar/-/commit/d7c8da0ed63729...
    Moved the added CSS library at the bottom of the file, without breaking the toolbar.tree library.

    Marking issue Fixed for now.

    Feel free to let us know if you have any questions or concerns on any of the changes merged in this ticket or the project in general, we would certainly be glad to help.
    Thanks in advance!

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

Production build 0.71.5 2024