From ee73c6859c456671109f2c2b3e0805b963456030 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Fri, 6 Sep 2019 23:09:28 +0100 Subject: [PATCH] Added Unit test --- tests/phpunit/CRM/Core/ResourcesTest.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/phpunit/CRM/Core/ResourcesTest.php b/tests/phpunit/CRM/Core/ResourcesTest.php index a00a9ca67a9a..45786d9de899 100644 --- a/tests/phpunit/CRM/Core/ResourcesTest.php +++ b/tests/phpunit/CRM/Core/ResourcesTest.php @@ -432,4 +432,28 @@ public function testIsFullyFormedUrl($url, $expected) { $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', + ]; + } + }