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