2 class Custom
extends CiviUnitTestCase
{
4 * Helper function to create Custom Group
6 * @deprecated - use functions on test case parent class
10 * @param bool $isMultiple
12 * @return object of created group
14 static function createGroup($group, $extends = NULL, $isMultiple = FALSE) {
16 if (isset($extends) &&
19 $extends = array($extends);
22 'title' => 'Test_Group',
23 'name' => 'test_group',
24 'extends' => $extends,
26 'is_multiple' => $isMultiple,
32 // this is done for backward compatibility
33 // with tests older than 3.2.3
34 if (isset($group['extends']) &&
35 !is_array($group['extends'])
37 $group['extends'] = array($group['extends']);
41 $result = civicrm_api('custom_group', 'create', $group);
43 if ($result['is_error']) {
47 // this is done for backward compatibility
48 // with tests older than 3.2.3
49 require_once 'CRM/Core/BAO/CustomGroup.php';
50 $group = new CRM_Core_BAO_CustomGroup();
51 $group->id
= $result['id'];
58 * Helper function to create Custom Field
59 * @deprecated use parent object create fn
62 * @return object of created field
64 static function createField($params, $fields = NULL) {
67 'custom_group_id' => $fields['groupId'],
68 'label' => empty($fields['label']) ?
'test_' . CRM_Utils_Array
::value('dataType', $fields) : $fields['label'],
69 'html_type' => CRM_Utils_Array
::value('htmlType', $fields),
70 'data_type' => CRM_Utils_Array
::value('dataType', $fields),
79 $result = civicrm_api('custom_field', 'create', $params);
81 if ($result['is_error']) {
86 // this is done for backward compatibility
87 // with tests older than 3.2.3
88 $customField = new CRM_Core_DAO_CustomField();
89 $customField->id
= $result['id'];
90 $customField->find(TRUE);
96 * Helper function to delete custom field
97 * @deprecated use function on parent class
98 * @param object of Custom Field to delete
100 static function deleteField($params) {
101 require_once 'CRM/Core/BAO/CustomField.php';
102 CRM_Core_BAO_CustomField
::deleteField($params);
106 * Helper function to delete custom group
107 * @deprecated use function on parent class
108 * @param object Custom Group to delete
109 * @return boolean true if Group deleted, false otherwise
111 static function deleteGroup($params) {
112 require_once 'CRM/Core/BAO/CustomGroup.php';
113 $deleteCustomGroup = CRM_Core_BAO_CustomGroup
::deleteGroup($params, TRUE);
114 return $deleteCustomGroup;