Added Unit test
authorPradeep Nayak <pradpnayak@gmail.com>
Fri, 6 Sep 2019 22:09:28 +0000 (23:09 +0100)
committerPradeep Nayak <pradpnayak@gmail.com>
Fri, 6 Sep 2019 22:41:40 +0000 (23:41 +0100)
CRM/Utils/Hook.php
tests/phpunit/CRM/Core/ResourcesTest.php

index 2c67541009117e42f9f71e1c0b6e17eb625f79bf..39bca82735f27d45ea66eebb6ba344a3562e3816 100644 (file)
@@ -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,
index a00a9ca67a9ab0d4ae86299fa91b16e14f138c86..45786d9de899d0bcf99accc6743e83fa8169be31 100644 (file)
@@ -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',
+    ];
+  }
+
 }