From 8b3edc18ff94ddbff03b61762defb51e2729045f Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 19 Sep 2014 12:22:46 -0400 Subject: [PATCH] CRM-15333 - CRM_Utils_HookTest - Verify that return values are properly merged. --- tests/phpunit/CRM/Utils/HookTest.php | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/phpunit/CRM/Utils/HookTest.php b/tests/phpunit/CRM/Utils/HookTest.php index a9b678b32d..22c165b346 100644 --- a/tests/phpunit/CRM/Utils/HookTest.php +++ b/tests/phpunit/CRM/Utils/HookTest.php @@ -18,6 +18,8 @@ class CRM_Utils_HookTest extends CiviUnitTestCase { 'hooktesta', 'hooktestb', 'hooktestc', + 'hooktestd', + 'hookteste', ); // our goal is to test a helper in CRM_Utils_Hook, but we need a concrete class $this->hook = new CRM_Utils_Hook_UnitTests(); @@ -48,6 +50,21 @@ class CRM_Utils_HookTest extends CiviUnitTestCase { $this->log ); } + + /** + * Verify that the results of runHooks() are correctly merged + */ + function testRunHooks_merge() { + $result = $this->hook->runHooks($this->fakeModules, 'civicrm_testRunHooks_merge', 0, CRM_Utils_Hook::$_nullObject, CRM_Utils_Hook::$_nullObject, CRM_Utils_Hook::$_nullObject, CRM_Utils_Hook::$_nullObject, CRM_Utils_Hook::$_nullObject, CRM_Utils_Hook::$_nullObject); + $this->assertEquals( + array( + 'from-module-a1', + 'from-module-a2', + 'from-module-e', + ), + $result + ); + } } /* --- Library of test hook implementations ---- */ @@ -78,3 +95,21 @@ function hooktestb_civicrm_testRunHooks_inner() { $test = CRM_Utils_HookTest::$activeTest; $test->log[] = 'b-inner'; } + +function hooktesta_civicrm_testRunHooks_merge() { + return array('from-module-a1', 'from-module-a2'); +} + +// OMIT: function hooktestb_civicrm_testRunHooks_merge + +function hooktestc_civicrm_testRunHooks_merge() { + return array(); +} + +function hooktestd_civicrm_testRunHooks_merge() { + return NULL; +} + +function hookteste_civicrm_testRunHooks_merge() { + return array('from-module-e'); +} -- 2.25.1