2 class Custom
extends CiviUnitTestCase
{
4 * Helper function to create Custom Group
6 * @deprecated - use functions on test case parent class
7 * @return object of created group
9 static function createGroup($group, $extends = NULL, $isMultiple = FALSE) {
11 if (isset($extends) &&
14 $extends = array($extends);
17 'title' => 'Test_Group',
18 'name' => 'test_group',
19 'extends' => $extends,
21 'is_multiple' => $isMultiple,
27 // this is done for backward compatibility
28 // with tests older than 3.2.3
29 if (isset($group['extends']) &&
30 !is_array($group['extends'])
32 $group['extends'] = array($group['extends']);
36 $result = civicrm_api('custom_group', 'create', $group);
38 if ($result['is_error']) {
42 // this is done for backward compatibility
43 // with tests older than 3.2.3
44 require_once 'CRM/Core/BAO/CustomGroup.php';
45 $group = new CRM_Core_BAO_CustomGroup();
46 $group->id
= $result['id'];
53 * Helper function to create Custom Field
54 * @deprecated use parent object create fn
55 * @return object of created field
57 static function createField($params, $fields = NULL) {
60 'custom_group_id' => $fields['groupId'],
61 'label' => empty($fields['label']) ?
'test_' . CRM_Utils_Array
::value('dataType', $fields) : $fields['label'],
62 'html_type' => CRM_Utils_Array
::value('htmlType', $fields),
63 'data_type' => CRM_Utils_Array
::value('dataType', $fields),
72 $result = civicrm_api('custom_field', 'create', $params);
74 if ($result['is_error']) {
79 // this is done for backward compatibility
80 // with tests older than 3.2.3
81 $customField = new CRM_Core_DAO_CustomField();
82 $customField->id
= $result['id'];
83 $customField->find(TRUE);
89 * Helper function to delete custom field
90 * @deprecated use function on parent class
91 * @param object of Custom Field to delete
93 static function deleteField($params) {
94 require_once 'CRM/Core/BAO/CustomField.php';
95 CRM_Core_BAO_CustomField
::deleteField($params);
99 * Helper function to delete custom group
100 * @deprecated use function on parent class
101 * @param object Custom Group to delete
102 * @return boolean true if Group deleted, false otherwise
104 static function deleteGroup($params) {
105 require_once 'CRM/Core/BAO/CustomGroup.php';
106 $deleteCustomGroup = CRM_Core_BAO_CustomGroup
::deleteGroup($params, TRUE);
107 return $deleteCustomGroup;