2 require_once 'CiviTest/CiviUnitTestCase.php';
3 class CRM_Utils_HookTest
extends CiviUnitTestCase
{
5 static $activeTest = NULL;
13 $this->fakeModules
= array(
18 // our goal is to test a helper in CRM_Utils_Hook, but we need a concrete class
19 $this->hook
= new CRM_Utils_Hook_UnitTests();
21 self
::$activeTest = $this;
25 self
::$activeTest = $this;
30 * Verify that runHooks() is reentrant by invoking one hook which calls another hooks
32 function testRunHooks_reentrancy() {
34 $this->hook
->runHooks($this->fakeModules
, 'civicrm_testRunHooks_outer', 1, $arg1, CRM_Utils_Hook
::$_nullObject, CRM_Utils_Hook
::$_nullObject, CRM_Utils_Hook
::$_nullObject, CRM_Utils_Hook
::$_nullObject);
49 /* --- Library of test hook implementations ---- */
51 function hooktesta_civicrm_testRunHooks_outer() {
52 $test = CRM_Utils_HookTest
::$activeTest;
53 $test->log
[] = 'a-outer';
56 function hooktestb_civicrm_testRunHooks_outer() {
57 $test = CRM_Utils_HookTest
::$activeTest;
58 $test->log
[] = 'b-outer-1';
59 $test->hook
->runHooks($test->fakeModules
, 'civicrm_testRunHooks_inner', 0, CRM_Utils_Hook
::$_nullObject, CRM_Utils_Hook
::$_nullObject, CRM_Utils_Hook
::$_nullObject, CRM_Utils_Hook
::$_nullObject, CRM_Utils_Hook
::$_nullObject);
60 $test->log
[] = 'b-outer-2';
63 function hooktestc_civicrm_testRunHooks_outer() {
64 $test = CRM_Utils_HookTest
::$activeTest;
65 $test->log
[] = 'c-outer';
68 function hooktesta_civicrm_testRunHooks_inner() {
69 $test = CRM_Utils_HookTest
::$activeTest;
70 $test->log
[] = 'a-inner';
73 function hooktestb_civicrm_testRunHooks_inner() {
74 $test = CRM_Utils_HookTest
::$activeTest;
75 $test->log
[] = 'b-inner';