Problem/Motivation
In more recent iterations and code changes (see related issues), new Functional test classes were added to test the three modules admin settings forms:
- \Drupal\Tests\admin_toolbar_search\Functional\AdminToolbarSearchSettingsFormTest
- \Drupal\Tests\admin_toolbar_tools\Functional\AdminToolbarToolsSettingsFormTest
- \Drupal\Tests\admin_toolbar\Functional\AdminToolbarSettingsFormTest
It now appears certain Functional test classes that existed previously could potentially be merged or included in recently added test classes listed above.
This would reduce the number of Functional tests files in the project, in particular for smaller test classes, where few assertions are processed, see:
- \Drupal\Tests\admin_toolbar_search\Functional\AdminToolbarSearchSettingTest
- \Drupal\Tests\admin_toolbar_tools\Functional\AdminToolbarToolsAlterTest
- \Drupal\Tests\admin_toolbar\Functional\AdminToolbarAlterTest
The setup of the tests could be grouped and the assertions from these tests could be moved to the corresponding module's settings form Functional test class.
I would "guess" these classes were added at very early stages of the project (back in 2015) as a basis for implementing Functional tests, with the intention of expanding and building on them as the module would evolve.
But at this point, we have already developed our own set of tests classes and therefore these older ones should not be needed anymore.
Steps to reproduce
Run PHPUNIT Functional tests.
Proposed resolution
1 - Merge class \Drupal\Tests\admin_toolbar_search\Functional\AdminToolbarSearchSettingTest into \Drupal\Tests\admin_toolbar_search\Functional\AdminToolbarSearchSettingsFormTest:
The values of the Admin Toolbar Search configuration (admin_toolbar_search.settings
) are already updated/changed in class AdminToolbarSearchSettingsFormTest, so we would just need to check for the display of the relevant HTML IDs of the module.
Additionally, we could improve the Functional test class by testing the permission 'use admin toolbar search'
, instead of testing this in FunctionalJavascript \Drupal\Tests\admin_toolbar_search\FunctionalJavascript\AdminToolbarSearchTest
==> To be removed in a different ticket.
Also add checks for the route '/admin/admin-toolbar-search'
to test access control with the permission.
2 - Merge class \Drupal\Tests\admin_toolbar_tools\Functional\AdminToolbarToolsAlterTest into \Drupal\Tests\admin_toolbar_tools\Functional\AdminToolbarToolsSettingsFormTest:
Move a single assertion.
3 - Merge class \Drupal\Tests\admin_toolbar\Functional\AdminToolbarAlterTest into \Drupal\Tests\admin_toolbar\Functional\AdminToolbarSettingsFormTest:
Move a single assertion.