6 class Custom
extends CiviUnitTestCase
{
8 * Helper function to create Custom Group.
10 * @deprecated - use functions on test case parent class
13 * @param null $extends
14 * @param bool $isMultiple
19 public static function createGroup($group, $extends = NULL, $isMultiple = FALSE) {
21 if (isset($extends) &&
24 $extends = array($extends);
27 'title' => 'Test_Group',
28 'name' => 'test_group',
29 'extends' => $extends,
31 'is_multiple' => $isMultiple,
37 // this is done for backward compatibility
38 // with tests older than 3.2.3
39 if (isset($group['extends']) &&
40 !is_array($group['extends'])
42 $group['extends'] = array($group['extends']);
46 $result = civicrm_api('custom_group', 'create', $group);
48 if ($result['is_error']) {
52 // this is done for backward compatibility
53 // with tests older than 3.2.3
54 require_once 'CRM/Core/BAO/CustomGroup.php';
55 $group = new CRM_Core_BAO_CustomGroup();
56 $group->id
= $result['id'];
63 * Helper function to create Custom Field.
64 * @deprecated use parent object create fn
65 * @param array $params
70 public static function createField($params, $fields = NULL) {
73 'custom_group_id' => $fields['groupId'],
74 'label' => empty($fields['label']) ?
'test_' . CRM_Utils_Array
::value('dataType', $fields) : $fields['label'],
75 'html_type' => CRM_Utils_Array
::value('htmlType', $fields),
76 'data_type' => CRM_Utils_Array
::value('dataType', $fields),
85 $result = civicrm_api('custom_field', 'create', $params);
87 if ($result['is_error']) {
92 // this is done for backward compatibility
93 // with tests older than 3.2.3
94 $customField = new CRM_Core_DAO_CustomField();
95 $customField->id
= $result['id'];
96 $customField->find(TRUE);
102 * Helper function to delete custom field.
104 * @deprecated use function on parent class
108 public static function deleteField($params) {
109 CRM_Core_BAO_CustomField
::deleteField($params);
113 * Helper function to delete custom group.
115 * @deprecated use function on parent class
120 * true if Group deleted, false otherwise
122 public static function deleteGroup($params) {
123 $deleteCustomGroup = CRM_Core_BAO_CustomGroup
::deleteGroup($params, TRUE);
124 return $deleteCustomGroup;