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
16 * @return object of created group
18 static function createGroup($group, $extends = NULL, $isMultiple = FALSE) {
20 if (isset($extends) &&
23 $extends = array($extends);
26 'title' => 'Test_Group',
27 'name' => 'test_group',
28 'extends' => $extends,
30 'is_multiple' => $isMultiple,
36 // this is done for backward compatibility
37 // with tests older than 3.2.3
38 if (isset($group['extends']) &&
39 !is_array($group['extends'])
41 $group['extends'] = array($group['extends']);
45 $result = civicrm_api('custom_group', 'create', $group);
47 if ($result['is_error']) {
51 // this is done for backward compatibility
52 // with tests older than 3.2.3
53 require_once 'CRM/Core/BAO/CustomGroup.php';
54 $group = new CRM_Core_BAO_CustomGroup();
55 $group->id
= $result['id'];
62 * Helper function to create Custom Field
63 * @deprecated use parent object create fn
66 * @return object of created field
68 static function createField($params, $fields = NULL) {
71 'custom_group_id' => $fields['groupId'],
72 'label' => empty($fields['label']) ?
'test_' . CRM_Utils_Array
::value('dataType', $fields) : $fields['label'],
73 'html_type' => CRM_Utils_Array
::value('htmlType', $fields),
74 'data_type' => CRM_Utils_Array
::value('dataType', $fields),
83 $result = civicrm_api('custom_field', 'create', $params);
85 if ($result['is_error']) {
90 // this is done for backward compatibility
91 // with tests older than 3.2.3
92 $customField = new CRM_Core_DAO_CustomField();
93 $customField->id
= $result['id'];
94 $customField->find(TRUE);
100 * Helper function to delete custom field
101 * @deprecated use function on parent class
102 * @param object of Custom Field to delete
104 static function deleteField($params) {
105 require_once 'CRM/Core/BAO/CustomField.php';
106 CRM_Core_BAO_CustomField
::deleteField($params);
110 * Helper function to delete custom group
111 * @deprecated use function on parent class
112 * @param object Custom Group to delete
113 * @return boolean true if Group deleted, false otherwise
115 static function deleteGroup($params) {
116 require_once 'CRM/Core/BAO/CustomGroup.php';
117 $deleteCustomGroup = CRM_Core_BAO_CustomGroup
::deleteGroup($params, TRUE);
118 return $deleteCustomGroup;