CRM-12595 fix formatting in tests files
[civicrm-core.git] / tests / phpunit / api / v3 / EventTest.php
CommitLineData
6a488035 1<?php
6a488035
TO
2
3/*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.3 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
27*/
28
29
30require_once 'CiviTest/CiviUnitTestCase.php';
31class api_v3_EventTest extends CiviUnitTestCase {
32 protected $_params;
33 protected $_apiversion;
34 protected $_entity; function get_info() {
35 return array(
36 'name' => 'Event Create',
37 'description' => 'Test all Event Create API methods.',
38 'group' => 'CiviCRM API Tests',
39 );
40 }
41
42 function setUp() {
43 parent::setUp();
44 $this->_apiversion = 3;
45 $this->_entity = 'event';
46 $this->_params = array(
47 array(
48 'title' => 'Annual CiviCRM meet',
49 'summary' => 'If you have any CiviCRM realted issues or want to track where CiviCRM is heading, Sign up now',
50 'description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues',
51 'event_type_id' => 1,
52 'is_public' => 1,
53 'start_date' => 20081021,
54 'end_date' => 20081023,
55 'is_online_registration' => 1,
56 'registration_start_date' => 20080601,
57 'registration_end_date' => '2008-10-15',
58 'max_participants' => 100,
59 'event_full_text' => 'Sorry! We are already full',
60 'is_monetary' => 0,
61 'is_active' => 1,
62 'is_show_location' => 0,
63 'version' => $this->_apiversion,
64 ),
65 array(
66 'title' => 'Annual CiviCRM meet 2',
67 'summary' => 'If you have any CiviCRM realted issues or want to track where CiviCRM is heading, Sign up now',
68 'description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues',
69 'event_type_id' => 1,
70 'is_public' => 1,
71 'start_date' => 20101021,
72 'end_date' => 20101023,
73 'is_online_registration' => 1,
74 'registration_start_date' => 20100601,
75 'registration_end_date' => '2010-10-15',
76 'max_participants' => 100,
77 'event_full_text' => 'Sorry! We are already full',
78 'is_monetory' => 0,
79 'is_active' => 1,
80 'is_show_location' => 0,
81 'version' => $this->_apiversion,
82 ),
83 );
84
85 $params = array(
86 array(
87 'title' => 'Annual CiviCRM meet',
88 'event_type_id' => 1,
89 'start_date' => 20081021,
90 'version' => $this->_apiversion,
91 ),
92 array(
93 'title' => 'Annual CiviCRM meet 2',
94 'event_type_id' => 1,
95 'start_date' => 20101021,
96 'version' => $this->_apiversion,
97 ),
98 );
99
100 $this->events = array();
101 $this->eventIds = array();
102 foreach ($params as $event) {
103 $result = civicrm_api('Event', 'Create', $event);
104 $this->_events[] = $result;
105 $this->_eventIds[] = $result['id'];
106 }
107 }
108
109 function tearDown() {
110 foreach ($this->eventIds as $eventId) {
111 $this->eventDelete($eventId);
112 }
113
114 /*
115 if ($this->_eventId) {
116 $this->eventDelete($this->_eventId);
117 }
118 $this->eventDelete($this->_event['id']);
119 */
120
121
122 $tablesToTruncate = array(
123 'civicrm_participant',
124 'civicrm_event',
125 );
126 $this->quickCleanup($tablesToTruncate, TRUE);
127 }
128
129 ///////////////// civicrm_event_get methods
130 function testGetWrongParamsType() {
131 $params = 'Annual CiviCRM meet';
132 $result = civicrm_api('Event', 'Get', $params);
133
134 $this->assertEquals($result['is_error'], 1);
135 }
136
137 function testGetEventEmptyParams() {
138 $params = array();
139 $result = civicrm_api('event', 'get', $params);
140
141 $this->assertEquals($result['is_error'], 1);
142 }
143
144 function testGetEventById() {
145 $params = array(
146 'id' => $this->_events[1]['id'],
147 'version' => $this->_apiversion,
148 );
149 $result = civicrm_api('event', 'get', $params);
150 $this->assertEquals($result['values'][$this->_eventIds[1]]['event_title'], 'Annual CiviCRM meet 2');
151 }
152
153 function testGetEventByEventTitle() {
154
155 $params = array(
156 'event_title' => 'Annual CiviCRM meet',
157 'version' => $this->_apiversion,
158 );
159
160 $result = civicrm_api('event', 'get', $params);
161 $this->documentMe($params, $result, __FUNCTION__, __FILE__);
162 $this->assertEquals(1, $result['count']);
163 $this->assertEquals($result['values'][0]['id'], $this->_eventIds[0]['id']);
164 }
165
166 function testGetEventByWrongTitle() {
167 $params = array(
168 'title' => 'No event with that title',
169 'version' => $this->_apiversion,
170 );
171 $result = civicrm_api('Event', 'Get', $params);
172 $this->assertEquals(0, $result['count']);
173 }
174 function testGetEventByIdSort() {
b6708aeb 175 $params = array(
6a488035
TO
176 'return.sort' => 'id ASC',
177 'return.max_results' => 1,
178 'version' => $this->_apiversion,
179 );
180 $result = civicrm_api('Event', 'Get', $params);
181 $this->assertEquals(1, $result['id'], ' in line ' . __LINE__);
182 $params = array(
183 'options' => array(
184 'sort' => 'id DESC',
185 'limit' => 1,
186 ),
187 'version' => $this->_apiversion,
188 );
189
190 $result = civicrm_api('Event', 'Get', $params);
191 $this->assertAPISuccess($result, ' in line ' . __LINE__);
192 $this->assertEquals(2, $result['id'], ' in line ' . __LINE__);
193 $params = array(
194 'options' => array(
195 'sort' => 'id ASC',
196 'limit' => 1,
197 ),
198 'version' => $this->_apiversion,
199 );
200 $result = civicrm_api('Event', 'Get', $params);
201 $this->assertEquals(1, $result['id'], ' in line ' . __LINE__);
202
203
204 }
205 /*
206 * Getting the id back of an event.
207 * Does not work yet, bug in API
208 */
209
210 /*
211 function testGetIdOfEventByEventTitle() {
212 $params = array(
213 'version' => $this->_apiversion,
214 'title' => 'Annual CiviCRM meet',
215 'return' => 'id'
216 );
217
218 $result = civicrm_api('Event', 'Get', $params);
219 }
220 */
221
222
223 /*
224 * Test 'is.Current' option. Existing event is 'old' so only current should be returned
225 */
226 function testGetIsCurrent() {
227 $params = array(
228 'version' => $this->_apiversion,
229 'isCurrent' => 1,
230 );
231 $currentEventParams = array('start_date' => date('Y-m-d', strtotime('+ 1 day')),
232 'end_date' => date('Y-m-d', strtotime('+ 1 week')),
233 );
234 $currentEventParams = array_merge($this->_params[1], $currentEventParams);
235 $currentEvent = civicrm_api('Event', 'Create', $currentEventParams);
236 $description = "demonstrates use of is.Current option";
237 $subfile = "IsCurrentOption";
238 $result = civicrm_api('Event', 'Get', $params);
239
240 $this->documentMe($params, $result, __FUNCTION__, __FILE__, $description, $subfile);
241 $allEvents = civicrm_api('Event', 'Get', array('version' => 3));
242 civicrm_api('Event', 'Delete', array('version' => 3, 'id' => $currentEventParams['id']));
243 $this->assertEquals(1, $result['count'], 'confirm only one event found in line ' . __LINE__);
244 $this->assertEquals(3, $allEvents['count'], 'confirm three events exist (ie. two not found) ' . __LINE__);
245 $this->assertEquals($currentEvent['id'], $result['id'], '');
246 }
247/*
248 * There has been a schema change & the api needs to buffer developers from it
249 */
250 function testGetPaymentProcessorId() {
251 $params = $this->_params[0];
252 $params['payment_processor_id'] = 1;
253 $params['sequential'] =1;
254 $result = civicrm_api('event', 'create', $params);
255 $this->assertEquals( 1,$result['values'][0]['payment_processor'][0], "handing of payment processor compatibility");
256 $result = civicrm_api('event', 'get', $params);
257 $this->assertEquals($result['values'][0]['payment_processor_id'], 1,"handing get payment processor compatibility");
258 }
259
260 function testInvalidData() {
261 $params = $this->_params[0];
262 $params['sequential'] =1;
263 $params['loc_block_id'] =100;
264 $result = civicrm_api('event', 'create', $params);
265 $this->assertEquals(1, $result['is_error']);
266
267 }
268
269 /*
270 * Test 'is.Current' option. Existing event is 'old' so only current should be returned
271 */
272 function testGetSingleReturnIsFull() {
273 $contactID = $this->individualCreate();
274 $params = array(
275 'id' => $this->_eventIds[0],
276 'version' => $this->_apiversion,
277 'max_participants' => 1,
278 );
279 $result = civicrm_api('Event', 'Create', $params);
280
281 $getEventParams = array(
282 'id' => $this->_eventIds[0],
283 'version' => $this->_apiversion,
284 'return.is_full' => 1,
285 );
286
287 $currentEvent = civicrm_api('Event', 'getsingle', $getEventParams);
288 $description = "demonstrates use of return is_full ";
289 $subfile = "IsFullOption";
290 $this->assertEquals(0, $currentEvent['is_full'], ' is full is set in line ' . __LINE__);
291 $this->assertEquals(1, $currentEvent['available_places'], 'available places is set in line ' . __LINE__);
292 $participant = civicrm_api('Participant', 'create', array('version' => 3, 'participant_status' => 1, 'role_id' => 1, 'contact_id' => $contactID, 'event_id' => $this->_eventIds[0]));
293 $currentEvent = civicrm_api('Event', 'getsingle', $getEventParams);
294
295 $this->documentMe($getEventParams, $currentEvent, __FUNCTION__, __FILE__, $description, $subfile, 'getsingle');
296 $this->assertEquals(1, $currentEvent['is_full'], ' is full is set in line ' . __LINE__);
297 $this->assertEquals(0, $currentEvent['available_places'], 'available places is set in line ' . __LINE__);
298
299 $this->contactDelete($contactID);
300 }
301 /*
302 * Legacy support for Contribution Type ID. We need to ensure this is supported
303 * as an alias for financial_type_id
304 */
305 function testCreateGetEventLegacyContributionTypeID() {
306 $contributionTypeArray = array('contribution_type_id' => 3);
307 if(isset($this->_params[0]['financial_type_id'])){
308 //in case someone edits $this->_params & invalidates this test :-)
309 unset($this->_params[0]['financial_type_id']);
310 }
311 $result = civicrm_api('event', 'create', $this->_params[0] + $contributionTypeArray);
312 $this->assertAPISuccess($result, ' Event Creation Failedon line ' . __LINE__);
313 $getresult = civicrm_api('event', 'get', array('version' => 3,) + $contributionTypeArray);
314 $this->assertAPISuccess($result, ' Event Creation on line ' . __LINE__);
ef0bc919 315 $this->assertEquals($getresult['values'][$getresult['id']]['contribution_type_id'], 3);
6a488035
TO
316 $this->assertEquals($result['id'], $getresult['id']);
317 civicrm_api('event', 'delete', array('version' => 3, 'id' => $result['id']));
318 }
319 ///////////////// civicrm_event_create methods
320
321 /**
322 * check with complete array + custom field
323 * Note that the test is written on purpose without any
324 * variables specific to participant so it can be replicated into other entities
325 * and / or moved to the automated test suite
326 */
327 function testCreateWithCustom() {
328 $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
329
330 $params = $this->_params[0];
331 $params['custom_' . $ids['custom_field_id']] = "custom string";
332
333 $result = civicrm_api($this->_entity, 'create', $params);
334 $this->documentMe($params, $result, __FUNCTION__, __FILE__);
335 $this->assertNotEquals($result['is_error'], 1, $result['error_message'] . ' in line ' . __LINE__);
336
337 $check = civicrm_api($this->_entity, 'get', array('version' => 3, 'return.custom_' . $ids['custom_field_id'] => 1, 'id' => $result['id']));
338 $this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);
339
340 $this->customFieldDelete($ids['custom_field_id']);
341 $this->customGroupDelete($ids['custom_group_id']);
342 civicrm_api($this->_entity, 'Delete', array('version' => 3, 'id' => $result['id']));
343 }
344
345 function testCreateEventParamsNotArray() {
346 $params = NULL;
347 $result = civicrm_api('event', 'create', $params);
348 $this->assertEquals(1, $result['is_error']);
349 }
350
351 function testCreateEventEmptyParams() {
352 $params = array();
353 $result = civicrm_api('event', 'create', $params);
354 $this->assertEquals($result['is_error'], 1);
355 }
356
357 function testCreateEventParamsWithoutTitle() {
358 unset($this->_params['title']);
359 $result = civicrm_api('event', 'create', $this->_params);
360 $this->assertEquals($result['is_error'], 1);
361 }
362
363 function testCreateEventParamsWithoutEventTypeId() {
364 unset($this->_params['event_type_id']);
365 $result = civicrm_api('event', 'create', $this->_params);
366 $this->assertEquals($result['is_error'], 1);
367 }
368
369 function testCreateEventParamsWithoutStartDate() {
370 unset($this->_params['start_date']);
371 $result = civicrm_api('event', 'create', $this->_params);
372 $this->assertEquals($result['is_error'], 1);
373 }
374
375 function testCreateEventSuccess() {
376 $result = civicrm_api('Event', 'Create', $this->_params[0]);
377 $this->documentMe($this->_params[0], $result, __FUNCTION__, __FILE__);
378 $this->assertEquals($result['is_error'], 0);
379 $this->assertArrayHasKey('id', $result['values'][$result['id']], 'In line ' . __LINE__);
380 $result = civicrm_api($this->_entity, 'Get', array('version' => 3, 'id' => $result['id']));
381 civicrm_api($this->_entity, 'Delete', array('version' => 3, 'id' => $result['id']));
382
383 $this->assertEquals('2008-10-21 00:00:00', $result['values'][$result['id']]['start_date'], 'start date is not set in line ' . __LINE__);
384 $this->assertEquals('2008-10-23 00:00:00', $result['values'][$result['id']]['end_date'], 'end date is not set in line ' . __LINE__);
385 $this->assertEquals('2008-06-01 00:00:00', $result['values'][$result['id']]['registration_start_date'], 'start date is not set in line ' . __LINE__);
386 $this->assertEquals('2008-10-15 00:00:00', $result['values'][$result['id']]['registration_end_date'], 'end date is not set in line ' . __LINE__);
387 civicrm_api($this->_entity, 'Delete', array('version' => 3, 'id' => $result['id']));
388 }
389 /*
390 * Test that passing in Unique field names works
391 */
392 function testCreateEventSuccessUniqueFieldNames() {
393 $this->_params[0]['event_start_date'] = $this->_params[0]['start_date'];
394 unset($this->_params[1]['start_date']);
395 $this->_params[0]['event_title'] = $this->_params[0]['title'];
396 unset($this->_params[0]['title']);
397 $result = civicrm_api('Event', 'Create', $this->_params[0]);
398 $this->assertAPISuccess($result, 'In line ' . __LINE__);
399 $this->assertArrayHasKey('id', $result['values'][$result['id']], 'In line ' . __LINE__);
400 $result = civicrm_api($this->_entity, 'Get', array('version' => 3, 'id' => $result['id']));
401 civicrm_api($this->_entity, 'Delete', array('version' => 3, 'id' => $result['id']));
402
403 $this->assertEquals('2008-10-21 00:00:00', $result['values'][$result['id']]['start_date'], 'start date is not set in line ' . __LINE__);
404 $this->assertEquals('2008-10-23 00:00:00', $result['values'][$result['id']]['end_date'], 'end date is not set in line ' . __LINE__);
405 $this->assertEquals('2008-06-01 00:00:00', $result['values'][$result['id']]['registration_start_date'], 'start date is not set in line ' . __LINE__);
406 $this->assertEquals('2008-10-15 00:00:00', $result['values'][$result['id']]['registration_end_date'], 'end date is not set in line ' . __LINE__);
407 $this->assertEquals($this->_params[0]['event_title'], $result['values'][$result['id']]['title'], 'end date is not set in line ' . __LINE__);
408
409 civicrm_api($this->_entity, 'Delete', array('version' => 3, 'id' => $result['id']));
410 }
411
412 function testUpdateEvent() {
413 $result = civicrm_api('event', 'create', $this->_params[1]);
414
415 $this->assertEquals($result['is_error'], 0);
416 $params = array(
417 'id' => $result['id'], 'version' => 3, 'max_participants' => 150,
418 );
419 civicrm_api('Event', 'Create', $params);
420 $updated = civicrm_api('Event', 'Get', $params);
421 $this->documentMe($this->_params, $updated, __FUNCTION__, __FILE__);
422 $this->assertEquals($updated['is_error'], 0);
423 $this->assertEquals(150, $updated['values'][$result['id']]['max_participants']);
424 $this->assertEquals('Annual CiviCRM meet 2', $updated['values'][$result['id']]['title']);
425 civicrm_api($this->_entity, 'Delete', array('version' => 3, 'id' => $result['id']));
426 }
427
428 ///////////////// civicrm_event_delete methods
429 function testDeleteWrongParamsType() {
430 $params = 'Annual CiviCRM meet';
431 $result = civicrm_api('Event', 'Delete', $params);
432
433 $this->assertEquals($result['is_error'], 1);
434 }
435
436 function testDeleteEmptyParams() {
437 $params = array();
438 $result = civicrm_api('Event', 'Delete', $params);
439 $this->assertEquals($result['is_error'], 1);
440 }
441
442 function testDelete() {
443 $params = array(
444 'id' => $this->_eventIds[0],
445 'version' => $this->_apiversion,
446 );
447 $result = civicrm_api('Event', 'Delete', $params);
448 $this->documentMe($params, $result, __FUNCTION__, __FILE__);
449 $this->assertNotEquals($result['is_error'], 1);
450 }
451 /*
452 * check event_id still supported for delete
453 */
454 function testDeleteWithEventId() {
455 $params = array(
456 'event_id' => $this->_eventIds[0],
457 'version' => $this->_apiversion,
458 );
459 $result = civicrm_api('Event', 'Delete', $params);
460 $this->assertAPISuccess($result, 'in line ' . __LINE__);
461 }
462 /*
463 * Trying to delete an event with participants should return error
464 */
465 function testDeleteWithExistingParticipant() {
466 $contactID = $this->individualCreate(NULL);
467 $participantID = $this->participantCreate(
468 array(
469 'contactID' => $contactID,
470 'eventID' => $this->_eventIds[0],
471 )
472 );
473 $result = civicrm_api('Event', 'Delete', array('version' => $this->_apiversion, 'id' => $this->_eventIds[0]));
474 $this->assertEquals(0, $result['is_error'], "Deleting exist with participants");
475 }
476
477 function testDeleteWithWrongEventId() {
478 $params = array('event_id' => $this->_eventIds[0], 'version' => $this->_apiversion);
479 $result = civicrm_api('Event', 'Delete', $params);
480 // try to delete again - there's no such event anymore
481 $params = array('event_id' => $this->_eventIds[0]);
482 $result = civicrm_api('Event', 'Delete', $params);
483 $this->assertEquals($result['is_error'], 1);
484 }
485
486 ///////////////// civicrm_event_search methods
487
488 /**
489 * Test civicrm_event_search with wrong params type
490 */
491 function testSearchWrongParamsType() {
492 $params = 'a string';
493 $result = civicrm_api('event', 'get', $params);
494
495 $this->assertEquals($result['is_error'], 1, 'In line ' . __LINE__);
496 }
497
498 /**
499 * Test civicrm_event_search with empty params
500 */
501 function testSearchEmptyParams() {
502 $event = civicrm_api('event', 'create', $this->_params[1]);
503
504 $getparams = array(
505 'version' => $this->_apiversion,
506 'sequential' => 1,
507 );
508 $result = civicrm_api('event', 'get', $getparams);
509 $this->assertEquals($result['count'], 3, 'In line ' . __LINE__);
510 $res = $result['values'][0];
511 $this->assertArrayKeyExists('title', $res, 'In line ' . __LINE__);
512 $this->assertEquals($res['event_type_id'], $this->_params[1]['event_type_id'], 'In line ' . __LINE__);
513 }
514
515 /**
516 * Test civicrm_event_search. Success expected.
517 */
518 function testSearch() {
519 $params = array(
520 'event_type_id' => 1,
521 'return.title' => 1,
522 'return.id' => 1,
523 'return.start_date' => 1,
524 'version' => $this->_apiversion,
525 );
526 $result = civicrm_api('event', 'get', $params);
527
528 $this->assertEquals($result['values'][$this->_eventIds[0]]['id'], $this->_eventIds[0], 'In line ' . __LINE__);
529 $this->assertEquals($result['values'][$this->_eventIds[0]]['title'], 'Annual CiviCRM meet', 'In line ' . __LINE__);
530 }
531
532 /**
533 * Test civicrm_event_search. Success expected.
534 * return.offset and return.max_results test (CRM-5266)
535 */
536 function testSearchWithOffsetAndMaxResults() {
537 $maxEvents = 5;
538 $events = array();
539 while ($maxEvents > 0) {
540 $params = array(
541 'version' => $this->_apiversion,
542 'title' => 'Test Event' . $maxEvents,
543 'event_type_id' => 2,
544 'start_date' => 20081021,
545 );
546
547 $events[$maxEvents] = civicrm_api('event', 'create', $params);
548 $maxEvents--;
549 }
550 $params = array(
551 'version' => $this->_apiversion,
552 'event_type_id' => 2,
553 'return.id' => 1,
554 'return.title' => 1,
555 'return.offset' => 2,
556 'return.max_results' => 2,
557 );
558 $result = civicrm_api('event', 'get', $params);
559 $this->assertAPISuccess($result);
560 $this->assertEquals(2, $result['count'], ' 2 results returned In line ' . __LINE__);
561 }
562
563 function testEventCreationPermissions() {
564 $params = array(
565 'event_type_id' => 1, 'start_date' => '2010-10-03', 'title' => 'le cake is a tie', 'check_permissions' => TRUE,
566 'version' => $this->_apiversion,
567 );
568 $config = &CRM_Core_Config::singleton();
569 $config->userPermissionClass->permissions = array('access CiviCRM');
570 $result = civicrm_api('event', 'create', $params);
571 $this->assertEquals(1, $result['is_error'], 'lacking permissions should not be enough to create an event');
572 $this->assertEquals('API permission check failed for event/create call; missing permission: access CiviEvent.', $result['error_message'], 'lacking permissions should not be enough to create an event');
573
574 $config->userPermissionClass->permissions = array('access CiviEvent', 'edit all events', 'access CiviCRM');
575 $result = civicrm_api('event', 'create', $params);
576 $this->assertEquals(0, $result['is_error'], 'overfluous permissions should be enough to create an event');
577 }
578
579 function testgetfields() {
580 $description = "demonstrate use of getfields to interogate api";
581 $params = array('version' => 3, 'action' => 'create');
582 $result = civicrm_api('event', 'getfields', $params);
583 $this->assertEquals(1, $result['values']['title']['api.required'], 'in line ' . __LINE__);
584 }
585 /*
586 * test api_action param also works
587 */
588 function testgetfieldsRest() {
589 $description = "demonstrate use of getfields to interogate api";
590 $params = array('version' => 3, 'api_action' => 'create');
591 $result = civicrm_api('event', 'getfields', $params);
592 $this->assertEquals(1, $result['values']['title']['api.required'], 'in line ' . __LINE__);
593 }
594 function testgetfieldsGet() {
595 $description = "demonstrate use of getfields to interogate api";
596 $params = array('version' => 3, 'action' => 'get');
597 $result = civicrm_api('event', 'getfields', $params);
598 $this->assertEquals('title', $result['values']['event_title']['name'], 'in line ' . __LINE__);
599 }
600 function testgetfieldsDelete() {
601 $description = "demonstrate use of getfields to interogate api";
602 $params = array('version' => 3, 'action' => 'delete');
603 $result = civicrm_api('event', 'getfields', $params);
604 $this->assertEquals(1, $result['values']['id']['api.required']);
605 }
606}
607