From 7022db93e1464ef74460fce2e524ba6e1f6d99f2 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Fri, 6 Sep 2019 23:09:28 +0100 Subject: [PATCH] Added Unit test --- CRM/Utils/Hook.php | 1 + tests/phpunit/CRM/Core/ResourcesTest.php | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 2c67541009..39bca82735 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -2498,6 +2498,7 @@ abstract class CRM_Utils_Hook { * @see CRM_Core_Resources::entityRefFilters * * @param array $filters + * @param array $links */ public static function entityRefFilters(&$filters, &$links = NULL) { self::singleton()->invoke(['filters', 'links'], $filters, $links, self::$_nullObject, diff --git a/tests/phpunit/CRM/Core/ResourcesTest.php b/tests/phpunit/CRM/Core/ResourcesTest.php index a00a9ca67a..45786d9de8 100644 --- a/tests/phpunit/CRM/Core/ResourcesTest.php +++ b/tests/phpunit/CRM/Core/ResourcesTest.php @@ -432,4 +432,28 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase { $this->assertEquals($expected, CRM_Core_Resources::isFullyFormedUrl($url)); } + /** + * Test for hook_civicrm_entityRefFilters(). + * + */ + public function testEntityRefFiltersHook() { + CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_entityRefFilters', [$this, 'entityRefFilters']); + $data = CRM_Core_Resources::getEntityRefMetadata(); + $this->assertEquals(count($data['links']['Contact']), 4); + $this->assertEquals(!empty($data['links']['Contact']['new_staff']), TRUE); + } + + /** + * @param array $filters + * @param array $links + */ + public function entityRefFilters(&$filters, &$links) { + $links['Contact']['new_staff'] = [ + 'label' => ts('New Staff'), + 'url' => '/civicrm/profile/create&reset=1&context=dialog&gid=5', + 'type' => 'Individual', + 'icon' => 'fa-user', + ]; + } + } -- 2.25.1