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