Merge pull request #17396 from seamuslee001/use_util_mail_events
[civicrm-core.git] / tests / phpunit / CRMTraits / Custom / CustomDataTrait.php
index 23f26fa62cd12e90fe28dd81148c978595f0d618..759d62a9d17b9b15805a66e75aa8b7b74b191521 100644 (file)
@@ -50,7 +50,7 @@ trait CRMTraits_Custom_CustomDataTrait {
       'max_multiple' => 0,
     ], $params);
     $identifier = $params['name'] ?? $params['title'];
-    $this->ids['CustomGroup'][$identifier] = CustomGroup::create()->setCheckPermissions(FALSE)->setValues($params)->execute()->first()['id'];
+    $this->ids['CustomGroup'][$identifier] = CustomGroup::create(FALSE)->setValues($params)->execute()->first()['id'];
     return $this->ids['CustomGroup'][$identifier];
   }
 
@@ -91,7 +91,7 @@ trait CRMTraits_Custom_CustomDataTrait {
    * @throws \Civi\API\Exception\UnauthorizedException
    */
   public function createCustomGroupWithFieldOfType($groupParams = [], $customFieldType = 'text', $identifier = NULL) {
-    $supported = ['text', 'select', 'date', 'int', 'contact_reference'];
+    $supported = ['text', 'select', 'date', 'int', 'contact_reference', 'radio'];
     if (!in_array($customFieldType, $supported, TRUE)) {
       throw new CRM_Core_Exception('we have not yet extracted other custom field types from createCustomFieldsOfAllTypes, Use consistent syntax when you do');
     }
@@ -120,6 +120,11 @@ trait CRMTraits_Custom_CustomDataTrait {
       case 'contact_reference':
         $reference = $this->createContactReferenceCustomField($fieldParams)['id'];
         return;
+
+      case 'radio':
+        $reference = $this->createIntegerRadioCustomField($fieldParams)['id'];
+        return;
+
     }
   }
 
@@ -329,6 +334,18 @@ trait CRMTraits_Custom_CustomDataTrait {
     return $this->callAPISuccess('custom_field', 'create', $params)['values'][0];
   }
 
+  /**
+   * Create a custom field of  type radio with integer values.
+   *
+   * @param array $params
+   *
+   * @return array
+   */
+  protected function createIntegerRadioCustomField($params): array {
+    $params = array_merge($this->getFieldsValuesByType('Int', 'Radio'), $params);
+    return $this->callAPISuccess('custom_field', 'create', $params)['values'][0];
+  }
+
   /**
    * Get default field values for the type of field.
    *
@@ -424,7 +441,7 @@ trait CRMTraits_Custom_CustomDataTrait {
         ],
         'CheckBox' => [
           'label' => 'Pick Color',
-          'html_type' => 'Checkbox',
+          'html_type' => 'CheckBox',
           'data_type' => 'String',
           'text_length' => '',
           'default_value' => '',
@@ -546,6 +563,12 @@ trait CRMTraits_Custom_CustomDataTrait {
               'weight' => 2,
               'is_active' => 1,
             ],
+            [
+              'label' => 'Red Testing',
+              'value' => 5,
+              'weight' => 3,
+              'is_active' => 1,
+            ],
           ],
         ],
       ],