Add kernel tests for hook system

Created on 17 August 2023, over 1 year ago
Updated 3 September 2023, about 1 year ago

(see also πŸ“Œ Improve unit test coverage for ModuleHandler RTBC )

Problem/Motivation

The hook system is currently covered directly by Drupal\Tests\Core\Extension\ModuleHandlerTest, and indirectly by various module tests that use hooks.

There are some shortcomings with this, which become apparent when we try to refactor the hook system, as in πŸ“Œ Hux-style hooks, proof of concept Needs work .

  • The coverage is insufficient: There are some bugs we can introduce that do not cause test fails in ModuleHandlerTest.
  • As a unit test, this one covers the class itself, instead of the "hook system". Currently this is mostly the same, but if we refactor it, the "hook system" will be a combination of classes, and their wiring as services.
  • The test relies heavily on mocking, including mocking of protected methods in ModuleHandler.
  • As a consequence, refactoring the hook system would require big changes in the ModuleHandlerTest, which makes it a poor solution for verifying that existing hooks still work as expected.

In πŸ“Œ Improve unit test coverage for ModuleHandler RTBC I propose changes to the Drupal\Tests\Core\Extension\ModuleHandlerTest.
But this does not change the main problem: As a unit test, the test covers specific classes, instead of the system in its real-world composition.

Steps to reproduce

See πŸ“Œ Hux-style hooks, proof of concept Needs work how many changes are needed in ModuleHandlerTest, as a consequence of the refactoring.

Proposed resolution

Add a kernel test to cover the hook system.

Remaining tasks

Is there anything in #7 to do?
Do no add a new word to dictionary.txt

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated about 19 hours ago

Created by

πŸ‡©πŸ‡ͺGermany donquixote

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

Comments & Activities

Production build 0.71.5 2024