Webtest fixes
[civicrm-core.git] / api / v3 / examples / Activity / Getfields.php
CommitLineData
22fd1690 1<?php
fb32de45 2/**
3 * Test Generated example of using activity getfields API
4 * *
22fd1690
ARW
5 */
6function activity_getfields_example(){
feb2a730 7$params = array(
22fd1690
ARW
8 'action' => 'create',
9);
10
fb32de45 11try{
12 $result = civicrm_api3('activity', 'getfields', $params);
13}
14catch (CiviCRM_API3_Exception $e) {
15 // handle error here
16 $errorMessage = $e->getMessage();
17 $errorCode = $e->getErrorCode();
18 $errorData = $e->getExtraParams();
19 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
20}
22fd1690 21
fb32de45 22return $result;
22fd1690
ARW
23}
24
fb32de45 25/**
22fd1690
ARW
26 * Function returns array of result expected from previous function
27 */
28function activity_getfields_expectedresult(){
29
feb2a730 30 $expectedResult = array(
22fd1690
ARW
31 'is_error' => 0,
32 'version' => 3,
feb2a730 33 'count' => 27,
34 'values' => array(
35 'source_record_id' => array(
22fd1690
ARW
36 'name' => 'source_record_id',
37 'type' => 1,
38 'title' => 'Source Record',
39 ),
feb2a730 40 'activity_type_id' => array(
22fd1690
ARW
41 'name' => 'activity_type_id',
42 'type' => 1,
43 'title' => 'Activity Type ID',
44 'required' => true,
45 'import' => true,
46 'where' => 'civicrm_activity.activity_type_id',
47 'headerPattern' => '/(activity.)?type(.id$)/i',
b259a4ab 48 'default' => '1',
feb2a730 49 'pseudoconstant' => array(
70f7ba9e
CW
50 'optionGroupName' => 'activity_type',
51 ),
22fd1690 52 ),
feb2a730 53 'activity_date_time' => array(
22fd1690
ARW
54 'name' => 'activity_date_time',
55 'type' => 12,
56 'title' => 'Activity Date',
57 'import' => true,
58 'where' => 'civicrm_activity.activity_date_time',
59 'headerPattern' => '/(activity.)?date(.time$)?/i',
60 'export' => true,
61 ),
feb2a730 62 'phone_id' => array(
22fd1690
ARW
63 'name' => 'phone_id',
64 'type' => 1,
65 'title' => 'Phone (called) ID',
66 'FKClassName' => 'CRM_Core_DAO_Phone',
67 ),
feb2a730 68 'phone_number' => array(
22fd1690
ARW
69 'name' => 'phone_number',
70 'type' => 2,
71 'title' => 'Phone (called) Number',
72 'maxlength' => 64,
73 'size' => 30,
74 ),
feb2a730 75 'priority_id' => array(
22fd1690
ARW
76 'name' => 'priority_id',
77 'type' => 1,
78 'title' => 'Priority',
feb2a730 79 'pseudoconstant' => array(
22fd1690
ARW
80 'optionGroupName' => 'priority',
81 ),
22fd1690 82 ),
feb2a730 83 'parent_id' => array(
22fd1690
ARW
84 'name' => 'parent_id',
85 'type' => 1,
86 'title' => 'Parent Activity Id',
87 'FKClassName' => 'CRM_Activity_DAO_Activity',
88 ),
feb2a730 89 'is_auto' => array(
22fd1690
ARW
90 'name' => 'is_auto',
91 'type' => 16,
92 'title' => 'Auto',
93 ),
feb2a730 94 'relationship_id' => array(
22fd1690
ARW
95 'name' => 'relationship_id',
96 'type' => 1,
97 'title' => 'Relationship Id',
b259a4ab 98 'default' => 'NULL',
22fd1690
ARW
99 'FKClassName' => 'CRM_Contact_DAO_Relationship',
100 ),
feb2a730 101 'is_current_revision' => array(
22fd1690
ARW
102 'name' => 'is_current_revision',
103 'type' => 16,
104 'title' => 'Is this activity a current revision in versioning chain?',
105 'import' => true,
106 'where' => 'civicrm_activity.is_current_revision',
107 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
108 'export' => true,
b259a4ab 109 'default' => '1',
22fd1690 110 ),
feb2a730 111 'original_id' => array(
22fd1690
ARW
112 'name' => 'original_id',
113 'type' => 1,
114 'title' => 'Original Activity ID ',
115 'FKClassName' => 'CRM_Activity_DAO_Activity',
116 ),
feb2a730 117 'weight' => array(
22fd1690
ARW
118 'name' => 'weight',
119 'type' => 1,
120 'title' => 'Weight',
121 ),
feb2a730 122 'id' => array(
22fd1690
ARW
123 'name' => 'id',
124 'type' => 1,
125 'title' => 'Activity ID',
126 'required' => true,
127 'import' => true,
128 'where' => 'civicrm_activity.id',
129 'export' => true,
130 'uniqueName' => 'activity_id',
feb2a730 131 'api.aliases' => array(
22fd1690
ARW
132 '0' => 'activity_id',
133 ),
134 ),
feb2a730 135 'subject' => array(
22fd1690
ARW
136 'name' => 'subject',
137 'type' => 2,
138 'title' => 'Subject',
139 'maxlength' => 255,
140 'size' => 45,
141 'import' => true,
142 'where' => 'civicrm_activity.subject',
143 'headerPattern' => '/(activity.)?subject/i',
144 'export' => true,
145 'uniqueName' => 'activity_subject',
146 ),
feb2a730 147 'duration' => array(
22fd1690
ARW
148 'name' => 'duration',
149 'type' => 1,
150 'title' => 'Duration',
151 'import' => true,
152 'where' => 'civicrm_activity.duration',
153 'headerPattern' => '/(activity.)?duration(s)?$/i',
154 'export' => true,
155 'uniqueName' => 'activity_duration',
156 ),
feb2a730 157 'location' => array(
22fd1690
ARW
158 'name' => 'location',
159 'type' => 2,
160 'title' => 'Location',
161 'maxlength' => 255,
162 'size' => 45,
163 'import' => true,
164 'where' => 'civicrm_activity.location',
165 'headerPattern' => '/(activity.)?location$/i',
166 'export' => true,
167 'uniqueName' => 'activity_location',
168 ),
feb2a730 169 'details' => array(
22fd1690
ARW
170 'name' => 'details',
171 'type' => 32,
172 'title' => 'Details',
173 'rows' => 8,
174 'cols' => 60,
175 'import' => true,
176 'where' => 'civicrm_activity.details',
177 'headerPattern' => '/(activity.)?detail(s)?$/i',
178 'export' => true,
179 'uniqueName' => 'activity_details',
180 ),
feb2a730 181 'status_id' => array(
22fd1690
ARW
182 'name' => 'status_id',
183 'type' => 1,
184 'title' => 'Activity Status Id',
185 'import' => true,
186 'where' => 'civicrm_activity.status_id',
187 'headerPattern' => '/(activity.)?status(.label$)?/i',
feb2a730 188 'pseudoconstant' => array(
70f7ba9e
CW
189 'optionGroupName' => 'activity_status',
190 ),
22fd1690 191 'uniqueName' => 'activity_status_id',
b259a4ab
EM
192 'api.aliases' => array(
193 '0' => 'activity_status',
194 ),
22fd1690 195 ),
feb2a730 196 'is_test' => array(
22fd1690
ARW
197 'name' => 'is_test',
198 'type' => 16,
199 'title' => 'Test',
200 'import' => true,
201 'where' => 'civicrm_activity.is_test',
202 'headerPattern' => '/(is.)?test(.activity)?/i',
203 'export' => true,
204 'uniqueName' => 'activity_is_test',
205 ),
feb2a730 206 'medium_id' => array(
22fd1690
ARW
207 'name' => 'medium_id',
208 'type' => 1,
209 'title' => 'Activity Medium',
b259a4ab 210 'default' => 'NULL',
feb2a730 211 'pseudoconstant' => array(
70f7ba9e
CW
212 'optionGroupName' => 'encounter_medium',
213 ),
22fd1690
ARW
214 'uniqueName' => 'activity_medium_id',
215 ),
feb2a730 216 'result' => array(
22fd1690
ARW
217 'name' => 'result',
218 'type' => 2,
219 'title' => 'Result',
220 'maxlength' => 255,
221 'size' => 45,
222 'uniqueName' => 'activity_result',
223 ),
feb2a730 224 'is_deleted' => array(
22fd1690
ARW
225 'name' => 'is_deleted',
226 'type' => 16,
227 'title' => 'Activity is in the Trash',
228 'import' => true,
229 'where' => 'civicrm_activity.is_deleted',
230 'headerPattern' => '/(activity.)?(trash|deleted)/i',
231 'export' => true,
232 'uniqueName' => 'activity_is_deleted',
233 ),
feb2a730 234 'campaign_id' => array(
22fd1690
ARW
235 'name' => 'campaign_id',
236 'type' => 1,
b259a4ab 237 'title' => 'Campaign',
22fd1690
ARW
238 'import' => true,
239 'where' => 'civicrm_activity.campaign_id',
240 'export' => true,
241 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
b259a4ab
EM
242 'pseudoconstant' => array(
243 'table' => 'civicrm_campaign',
244 'keyColumn' => 'id',
245 'labelColumn' => 'title',
246 ),
22fd1690
ARW
247 'uniqueName' => 'activity_campaign_id',
248 ),
feb2a730 249 'engagement_level' => array(
22fd1690
ARW
250 'name' => 'engagement_level',
251 'type' => 1,
252 'title' => 'Engagement Index',
253 'import' => true,
254 'where' => 'civicrm_activity.engagement_level',
255 'export' => true,
feb2a730 256 'pseudoconstant' => array(
70f7ba9e
CW
257 'optionGroupName' => 'engagement_index',
258 ),
22fd1690
ARW
259 'uniqueName' => 'activity_engagement_level',
260 ),
feb2a730 261 'source_contact_id' => array(
70f7ba9e
CW
262 'name' => 'source_contact_id',
263 'title' => 'Activity Source Contact',
264 'type' => 1,
265 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
22fd1690
ARW
266 'api.default' => 'user_contact_id',
267 ),
feb2a730 268 'assignee_contact_id' => array(
22fd1690
ARW
269 'name' => 'assignee_id',
270 'title' => 'assigned to',
271 'type' => 1,
70f7ba9e 272 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
22fd1690 273 ),
feb2a730 274 'target_contact_id' => array(
22fd1690
ARW
275 'name' => 'target_id',
276 'title' => 'Activity Target',
277 'type' => 1,
70f7ba9e 278 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
22fd1690 279 ),
22fd1690
ARW
280 ),
281);
282
fb32de45 283 return $expectedResult;
22fd1690
ARW
284}
285
286
287/*
288* This example has been generated from the API test suite. The test that created it is called
289*
290* testGetFields and can be found in
69d79249 291* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
22fd1690
ARW
292*
293* You can see the outcome of the API tests at
69d79249 294* https://test.civicrm.org/job/CiviCRM-master-git/
22fd1690
ARW
295*
296* To Learn about the API read
69d79249 297* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
22fd1690 298*
69d79249
E
299* Browse the api on your own site with the api explorer
300* http://MYSITE.ORG/path/to/civicrm/api/explorer
22fd1690
ARW
301*
302* Read more about testing here
303* http://wiki.civicrm.org/confluence/display/CRM/Testing
304*
305* API Standards documentation:
306* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 307*/