Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comment changes only #9931

Merged
merged 1 commit into from
Mar 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions CRM/Utils/Hook/UnitTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function reset() {
* Use a unit-testing mock object to handle hook invocations.
*
* e.g. hook_civicrm_foo === $mockObject->foo()
* Mocks with a magic `__call()` method are called for every hook invokation.
*
* @param object $mockObject
*/
Expand All @@ -60,7 +61,7 @@ public function setMock($mockObject) {
}

/**
* Register a piece of code to run when invoking a hook.
* Register a function to run when invoking a specific hook.
* @param string $hook
* Hook name, e.g civicrm_pre.
* @param array $callable
Expand All @@ -72,7 +73,7 @@ public function setHook($hook, $callable) {
}

/**
* Invoke hooks.
* Invoke standard, mock and ad hoc hooks.
*
* @param int $numParams
* Number of parameters to pass to the hook.
Expand All @@ -93,34 +94,22 @@ public function setHook($hook, $callable) {
*
* @return mixed
*/
/**
* @param int $numParams
* @param mixed $arg1
* @param mixed $arg2
* @param mixed $arg3
* @param mixed $arg4
* @param mixed $arg5
* @param mixed $arg6
* @param string $fnSuffix
*
* @return mixed
*/
public function invoke(
$numParams,
&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
$fnSuffix) {

$params = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6);

// run standard hooks
if ($this->civiModules === NULL) {
$this->civiModules = array();
$this->requireCiviModules($this->civiModules);
}
$this->runHooks($this->civiModules, $fnSuffix, $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);

// run mock object hooks
if ($this->mockObject && is_callable(array($this->mockObject, $fnSuffix))) {
call_user_func(array($this->mockObject, $fnSuffix), $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
}
// run adhoc hooks
if (!empty($this->adhocHooks[$fnSuffix])) {
call_user_func_array($this->adhocHooks[$fnSuffix], $params);
}
Expand Down