When using MediaWikiIntegrationTestCase::setTemporaryHook() in an integration test, it will stash any hooks defined in:
- Registered through HookContainer::register/Hooks::register()
- In extension.json (only if defined in the legacy way)
What it is currently lacking, is code to stash any new-style hook handlers defined in an extension.json. This causes problems because tests that were operating under the assumption that all existing hooks have been cleared for a clean slate, now risk having extension defined handlers interfere with tests and causes breakage.
- The hook container is reset after every test run anyway. We can just add hook handlers the usual way.
- A mechanism for temporary/scoped hook handlers is still needed for some rare use cases, but generally not useful for tests.
- Tests may want to suppress all other handlers for a hook, to ensure the testing handler is actually used.
- Unit tests (and most integration tests) may want to suppress all other handlers for all hooks, to ensure they are testing vanilla behavior. Compliance tests and structure tests however will need all hooks handlers registered by extensions to be in place.
- MediaWikiIntegrationTestCase::setTemporaryHook() just calls register() on the HookContainer. If the $replace flag is set, it calls clear() on the HookContainer first.
- Create MediaWikiIntegrationTestCase::clearAllHooks(), which replaces the default HookContaienr with an empty one.
- Ensure that HookContainer::scopedRegister() interacts correctly with hooks registered in different ways.
- Remove the $replace flag from HookContainer::scopedRegister() unless we are sure we really need it. If we do need it, implement it by creating an array of override handlers.