- /**
- * Find any hook functions in $test and register them.
- *
- * @param \Civi\Test\HookInterface $test
- */
- protected function registerHooks(HookInterface $test) {
- if (CIVICRM_UF !== 'UnitTests') {
- // This is not ideal -- it's just a side-effect of how hooks and E2E tests work.
- // We can temporarily subscribe to hooks in-process, but for other processes, it gets messy.
- throw new \RuntimeException('CiviHookTestInterface requires CIVICRM_UF=UnitTests');
- }
- \CRM_Utils_Hook::singleton()->reset();
- /** @var \CRM_Utils_Hook_UnitTests $hooks */
- $hooks = \CRM_Utils_Hook::singleton();
- foreach ($this->findTestHooks($test) as $hook => $func) {
- $hooks->setHook($hook, [$test, $func]);
- }
- }
-