Merge pull request #17253 from mattwire/utf8convertblocksize
[civicrm-core.git] / tests / phpunit / CRM / Core / BAO / UFFieldTest.php
index ba369748cd0cb480e42b30e111923d44b7a1a122..1cafb95c0e96248d06401da29f42a4022521d919 100644 (file)
@@ -218,4 +218,20 @@ class CRM_Core_BAO_UFFieldTest extends CiviUnitTestCase {
     return $ufGroup->id;
   }
 
+  /**
+   * Test ability to modify the acceptable fields for use in a profile via hook
+   */
+  public function testGetFieldsFlatModifiedByHook() {
+    unset(Civi::$statics['UFFieldsFlat']);
+    $this->hookClass->setHook('civicrm_alterUFFields', [$this, 'modifyUFFields']);
+    $fields = CRM_Core_BAO_UFField::getAvailableFieldsFlat();
+
+    $this->assertEquals('Grant', $fields['grant_id']['field_type']);
+    $this->assertEquals('contact_id', $fields['grant_contact_id']['name']);
+  }
+
+  public function modifyUFFields(&$fields) {
+    $fields['Grant'] = CRM_Grant_DAO_Grant::export();
+  }
+
 }