a['foo'] = 'a.name'; $e->b->bar = 'b.name'; }; \Civi::dispatcher()->addListener('hook_civicrm_e2eHookExample', $hookExample); try { $a = []; $b = new \stdClass(); $this->hookStub(['a', 'b'], $a, $b); $this->assertEquals(1, $calls); $this->assertEquals('a.name', $a['foo']); $this->assertEquals('b.name', $b->bar); } finally { \Civi::dispatcher()->removeListener('hook_civicrm_e2eHookExample', $hookExample); } } /** * @param mixed $names * @param array $a * @param \stdClass $b * @return mixed */ private function hookStub($names, &$a, $b) { return \CRM_Utils_Hook::singleton() ->invoke($names, $a, $b, \CRM_Utils_Hook::$_nullObject, \CRM_Utils_Hook::$_nullObject, \CRM_Utils_Hook::$_nullObject, \CRM_Utils_Hook::$_nullObject, 'civicrm_e2eHookExample'); } }