3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * Trait Custom Data trait.
31 * Trait for setting up custom data in tests.
33 trait CRMTraits_Custom_CustomDataTrait
{
36 * Create a custom group.
38 * @param array $params
42 public function createCustomGroup($params = []) {
43 $params = array_merge([
44 'title' => 'Custom Group',
45 'extends' => [$this->entity
],
50 $this->ids
['CustomGroup'][$params['title']] = $this->callAPISuccess('CustomGroup', 'create', $params)['id'];
51 return $this->ids
['CustomGroup'][$params['title']];
57 public function createCustomFieldsOfAllTypes() {
58 $customGroupID = $this->ids
['CustomGroup']['Custom Group'];
61 'custom_group_id' => $customGroupID,
62 'label' => 'Enter text here',
63 'html_type' => 'Text',
64 'data_type' => 'String',
65 'default_value' => 'xyz',
70 $customField = $this->callAPISuccess('CustomField', 'create', $params);
71 $ids[] = $customField['id'];
93 'label' => 'Pick Color',
94 'html_type' => 'Select',
95 'data_type' => 'String',
100 'option_values' => $optionValue,
101 'custom_group_id' => $customGroupID,
104 $customField = $this->callAPISuccess('custom_field', 'create', $params);
105 $ids[] = $customField['id'];
108 'custom_group_id' => $customGroupID,
109 'name' => 'test_date',
110 'label' => 'test_date',
111 'html_type' => 'Select Date',
112 'data_type' => 'Date',
113 'default_value' => '20090711',
116 'is_searchable' => 0,
120 $customField = $this->callAPISuccess('custom_field', 'create', $params);
122 $ids[] = $customField['id'];
124 'custom_group_id' => $customGroupID,
125 'name' => 'test_link',
126 'label' => 'test_link',
127 'html_type' => 'Link',
128 'data_type' => 'Link',
129 'default_value' => 'http://civicrm.org',
132 'is_searchable' => 0,
136 $customField = $this->callAPISuccess('custom_field', 'create', $params);
137 $ids[] = $customField['id'];