When using MediaWikiIntegrationTestCase::setTemporaryHook() in an integration test, it will stash any hooks defined in:
1. $wgHooks
2. Registered through HookContainer::register/Hooks::register()
3. 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.
After talking with @tstarling, he suggested that instead of just modifying HookContainer::scopedRegister(), it might be a better idea to replace usages of setTemporaryHook() with the creation of an empty hook container. The empty hook container could be passed to MediaWikiServices::redefineService() to test code that doesn't have a HookContainer passed in in a constructor.