From 5207a7ef44b739366096b8d2f41f6884dd56bc3d Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 23 Jul 2013 18:07:29 -0700 Subject: [PATCH] CRM_Utils_Hook_UnitTests - When running tests from an extension, the extension's hooks should still be called. --- CRM/Utils/Hook/UnitTests.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CRM/Utils/Hook/UnitTests.php b/CRM/Utils/Hook/UnitTests.php index 6004cff919..9ed86c8381 100644 --- a/CRM/Utils/Hook/UnitTests.php +++ b/CRM/Utils/Hook/UnitTests.php @@ -37,6 +37,7 @@ class CRM_Utils_Hook_UnitTests extends CRM_Utils_Hook { protected $mockObject; protected $adhocHooks; + protected $civiModules = NULL; // Call this in CiviUnitTestCase::setUp() function reset() { @@ -62,7 +63,15 @@ class CRM_Utils_Hook_UnitTests extends CRM_Utils_Hook { function invoke($numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, $fnSuffix) { + $params = array( &$arg1, &$arg2, &$arg3, &$arg4, &$arg5); + + if ($this->civiModules === NULL) { + $this->civiModules = array(); + $this->requireCiviModules($this->civiModules); + } + $this->runHooks($this->civiModules, $fnSuffix, $numParams, $arg1, $arg2, $arg3, $arg4, $arg5); + if ($this->mockObject && is_callable(array($this->mockObject, $fnSuffix))) { call_user_func(array($this->mockObject, $fnSuffix), $arg1, $arg2, $arg3, $arg4, $arg5); } -- 2.25.1