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