'is_monetary' => 0,
'is_active' => 1,
'is_show_location' => 0,
- 'version' => $this->_apiversion,
),
array(
'title' => 'Annual CiviCRM meet 2',
'is_monetory' => 0,
'is_active' => 1,
'is_show_location' => 0,
- 'version' => $this->_apiversion,
),
);
array(
'title' => 'Annual CiviCRM meet',
'event_type_id' => 1,
- 'start_date' => 20081021,
- 'version' => $this->_apiversion,
- ),
+ 'start_date' => 20081021, ),
array(
'title' => 'Annual CiviCRM meet 2',
'event_type_id' => 1,
- 'start_date' => 20101021,
- 'version' => $this->_apiversion,
- ),
+ 'start_date' => 20101021, ),
);
$this->events = array();
foreach ($this->eventIds as $eventId) {
$this->eventDelete($eventId);
}
-
- /*
- if ($this->_eventId) {
- $this->eventDelete($this->_eventId);
- }
- $this->eventDelete($this->_event['id']);
- */
-
-
$tablesToTruncate = array(
'civicrm_participant',
'civicrm_event',
function testGetEventById() {
$params = array(
- 'id' => $this->_events[1]['id'],
- 'version' => $this->_apiversion,
- );
- $result = civicrm_api('event', 'get', $params);
+ 'id' => $this->_events[1]['id'],);
+ $result = $this->callAPISuccess('event', 'get', $params);
$this->assertEquals($result['values'][$this->_eventIds[1]]['event_title'], 'Annual CiviCRM meet 2');
}
function testGetEventByWrongTitle() {
$params = array(
- 'title' => 'No event with that title',
- 'version' => $this->_apiversion,
- );
- $result = civicrm_api('Event', 'Get', $params);
+ 'title' => 'No event with that title',);
+ $result = $this->callAPISuccess('Event', 'Get', $params);
$this->assertEquals(0, $result['count']);
}
function testGetEventByIdSort() {
$params = array(
'return.sort' => 'id ASC',
- 'return.max_results' => 1,
- 'version' => $this->_apiversion,
- );
- $result = civicrm_api('Event', 'Get', $params);
+ 'return.max_results' => 1, );
+ $result = $this->callAPISuccess('Event', 'Get', $params);
$this->assertEquals(1, $result['id'], ' in line ' . __LINE__);
$params = array(
'options' => array(
'sort' => 'id DESC',
'limit' => 1,
- ),
- 'version' => $this->_apiversion,
- );
+ ), );
- $result = civicrm_api('Event', 'Get', $params);
+ $result = $this->callAPISuccess('Event', 'Get', $params);
$this->assertAPISuccess($result, ' in line ' . __LINE__);
$this->assertEquals(2, $result['id'], ' in line ' . __LINE__);
$params = array(
'options' => array(
'sort' => 'id ASC',
'limit' => 1,
- ),
- 'version' => $this->_apiversion,
- );
- $result = civicrm_api('Event', 'Get', $params);
+ ), );
+ $result = $this->callAPISuccess('Event', 'Get', $params);
$this->assertEquals(1, $result['id'], ' in line ' . __LINE__);
/*
function testGetIdOfEventByEventTitle() {
- $params = array(
- 'version' => $this->_apiversion,
- 'title' => 'Annual CiviCRM meet',
+ $params = array( 'title' => 'Annual CiviCRM meet',
'return' => 'id'
);
- $result = civicrm_api('Event', 'Get', $params);
+ $result = $this->callAPISuccess('Event', 'Get', $params);
}
*/
$params = $this->_params[0];
$params['payment_processor_id'] = 1;
$params['sequential'] =1;
- $result = civicrm_api('event', 'create', $params);
+ $result = $this->callAPISuccess('event', 'create', $params);
$this->assertEquals( 1,$result['values'][0]['payment_processor'][0], "handing of payment processor compatibility");
- $result = civicrm_api('event', 'get', $params);
+ $result = $this->callAPISuccess('event', 'get', $params);
$this->assertEquals($result['values'][0]['payment_processor_id'], 1,"handing get payment processor compatibility");
}
function testGetSingleReturnIsFull() {
$contactID = $this->individualCreate();
$params = array(
- 'id' => $this->_eventIds[0],
- 'version' => $this->_apiversion,
- 'max_participants' => 1,
+ 'id' => $this->_eventIds[0], 'max_participants' => 1,
);
- $result = civicrm_api('Event', 'Create', $params);
+ $result = $this->callAPISuccess('Event', 'Create', $params);
$getEventParams = array(
- 'id' => $this->_eventIds[0],
- 'version' => $this->_apiversion,
- 'return.is_full' => 1,
+ 'id' => $this->_eventIds[0], 'return.is_full' => 1,
);
- $currentEvent = civicrm_api('Event', 'getsingle', $getEventParams);
+ $currentEvent = $this->callAPISuccess('Event', 'getsingle', $getEventParams);
$description = "demonstrates use of return is_full ";
$subfile = "IsFullOption";
$this->assertEquals(0, $currentEvent['is_full'], ' is full is set in line ' . __LINE__);
$this->assertEquals(1, $currentEvent['available_places'], 'available places is set in line ' . __LINE__);
- $participant = civicrm_api('Participant', 'create', array('version' => 3, 'participant_status' => 1, 'role_id' => 1, 'contact_id' => $contactID, 'event_id' => $this->_eventIds[0]));
- $currentEvent = civicrm_api('Event', 'getsingle', $getEventParams);
-
- $this->documentMe($getEventParams, $currentEvent, __FUNCTION__, __FILE__, $description, $subfile, 'getsingle');
+ $participant = $this->callAPISuccess('Participant', 'create', array('participant_status' => 1, 'role_id' => 1, 'contact_id' => $contactID, 'event_id' => $this->_eventIds[0]));
+ $currentEvent = $this->callAPIAndDocument('Event', 'getsingle', $getEventParams, __FUNCTION__, __FILE__, $description, $subfile, 'getsingle');
$this->assertEquals(1, $currentEvent['is_full'], ' is full is set in line ' . __LINE__);
$this->assertEquals(0, $currentEvent['available_places'], 'available places is set in line ' . __LINE__);
//in case someone edits $this->_params & invalidates this test :-)
unset($this->_params[0]['financial_type_id']);
}
- $result = civicrm_api('event', 'create', $this->_params[0] + $contributionTypeArray);
- $this->assertAPISuccess($result, ' Event Creation Failedon line ' . __LINE__);
- $getresult = civicrm_api('event', 'get', array('version' => 3,) + $contributionTypeArray);
- $this->assertAPISuccess($result, ' Event Creation on line ' . __LINE__);
+ $result = $this->callAPISuccess('event', 'create', $this->_params[0] + $contributionTypeArray);
+ $getresult = $this->callAPISuccess('event', 'get', array() + $contributionTypeArray);
$this->assertEquals($getresult['values'][$getresult['id']]['contribution_type_id'], 3);
$this->assertEquals($result['id'], $getresult['id']);
- civicrm_api('event', 'delete', array('version' => 3, 'id' => $result['id']));
+ $this->callAPISuccess('event', 'delete', array('id' => $result['id']));
}
///////////////// civicrm_event_create methods
$result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
- $check = civicrm_api($this->_entity, 'get', array('version' => 3, 'return.custom_' . $ids['custom_field_id'] => 1, 'id' => $result['id']));
+ $check = $this->callAPISuccess($this->_entity, 'get', array('return.custom_' . $ids['custom_field_id'] => 1, 'id' => $result['id']));
$this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);
$this->customFieldDelete($ids['custom_field_id']);
$this->customGroupDelete($ids['custom_group_id']);
- civicrm_api($this->_entity, 'Delete', array('version' => 3, 'id' => $result['id']));
+ $this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id']));
}
function testCreateEventParamsNotArray() {
function testCreateEventParamsWithoutTitle() {
unset($this->_params['title']);
- $result = civicrm_api('event', 'create', $this->_params);
+ $result = $this->callAPIFailure('event', 'create', $this->_params);
$this->assertAPIFailure($result);
}
function testCreateEventParamsWithoutEventTypeId() {
unset($this->_params['event_type_id']);
- $result = civicrm_api('event', 'create', $this->_params);
- $this->assertAPIFailure($result);
+ $result = $this->callAPIFailure('event', 'create', $this->_params);
}
function testCreateEventParamsWithoutStartDate() {
unset($this->_params['start_date']);
- $result = civicrm_api('event', 'create', $this->_params);
- $this->assertAPIFailure($result);
+ $result = $this->callAPIFailure('event', 'create', $this->_params);
}
function testCreateEventSuccess() {
- $result = civicrm_api('Event', 'Create', $this->_params[0]);
- $this->documentMe($this->_params[0], $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result);
+ $result = $this->callAPIAndDocument('Event', 'Create', $this->_params[0], __FUNCTION__, __FILE__);
$this->assertArrayHasKey('id', $result['values'][$result['id']], 'In line ' . __LINE__);
- $result = civicrm_api($this->_entity, 'Get', array('version' => 3, 'id' => $result['id']));
- civicrm_api($this->_entity, 'Delete', array('version' => 3, 'id' => $result['id']));
-
+ $result = $this->callAPISuccess($this->_entity, 'Get', array('id' => $result['id']));
+ $this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id']));
$this->assertEquals('2008-10-21 00:00:00', $result['values'][$result['id']]['start_date'], 'start date is not set in line ' . __LINE__);
$this->assertEquals('2008-10-23 00:00:00', $result['values'][$result['id']]['end_date'], 'end date is not set in line ' . __LINE__);
$this->assertEquals('2008-06-01 00:00:00', $result['values'][$result['id']]['registration_start_date'], 'start date is not set in line ' . __LINE__);
$this->assertEquals('2008-10-15 00:00:00', $result['values'][$result['id']]['registration_end_date'], 'end date is not set in line ' . __LINE__);
- civicrm_api($this->_entity, 'Delete', array('version' => 3, 'id' => $result['id']));
}
/*
* Test that passing in Unique field names works
unset($this->_params[1]['start_date']);
$this->_params[0]['event_title'] = $this->_params[0]['title'];
unset($this->_params[0]['title']);
- $result = civicrm_api('Event', 'Create', $this->_params[0]);
+ $result = $this->callAPISuccess('Event', 'Create', $this->_params[0]);
$this->assertAPISuccess($result, 'In line ' . __LINE__);
$this->assertArrayHasKey('id', $result['values'][$result['id']], 'In line ' . __LINE__);
- $result = civicrm_api($this->_entity, 'Get', array('version' => 3, 'id' => $result['id']));
- civicrm_api($this->_entity, 'Delete', array('version' => 3, 'id' => $result['id']));
+ $result = $this->callAPISuccess($this->_entity, 'Get', array('id' => $result['id']));
+ $this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id']));
$this->assertEquals('2008-10-21 00:00:00', $result['values'][$result['id']]['start_date'], 'start date is not set in line ' . __LINE__);
$this->assertEquals('2008-10-23 00:00:00', $result['values'][$result['id']]['end_date'], 'end date is not set in line ' . __LINE__);
$this->assertEquals('2008-06-01 00:00:00', $result['values'][$result['id']]['registration_start_date'], 'start date is not set in line ' . __LINE__);
$this->assertEquals('2008-10-15 00:00:00', $result['values'][$result['id']]['registration_end_date'], 'end date is not set in line ' . __LINE__);
$this->assertEquals($this->_params[0]['event_title'], $result['values'][$result['id']]['title'], 'end date is not set in line ' . __LINE__);
-
- civicrm_api($this->_entity, 'Delete', array('version' => 3, 'id' => $result['id']));
}
function testUpdateEvent() {
- $result = civicrm_api('event', 'create', $this->_params[1]);
+ $result = $this->callAPISuccess('event', 'create', $this->_params[1]);
- $this->assertAPISuccess($result);
$params = array(
- 'id' => $result['id'], 'version' => 3, 'max_participants' => 150,
+ 'id' => $result['id'], 'max_participants' => 150,
);
- civicrm_api('Event', 'Create', $params);
- $updated = civicrm_api('Event', 'Get', $params);
- $this->documentMe($this->_params, $updated, __FUNCTION__, __FILE__);
- $this->assertEquals($updated['is_error'], 0);
+ $this->callAPISuccess('Event', 'Create', $params);
+ $updated = $this->callAPIAndDocument('Event', 'Get', $params, __FUNCTION__, __FILE__);
$this->assertEquals(150, $updated['values'][$result['id']]['max_participants']);
$this->assertEquals('Annual CiviCRM meet 2', $updated['values'][$result['id']]['title']);
- civicrm_api($this->_entity, 'Delete', array('version' => 3, 'id' => $result['id']));
+ $this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id']));
}
- ///////////////// civicrm_event_delete methods
- function testDeleteWrongParamsType() {
- $params = 'Annual CiviCRM meet';
- $result = $this->callAPIFailure('Event', 'Delete', $params);
- }
function testDeleteEmptyParams() {
- $params = array();
- $result = $this->callAPIFailure('Event', 'Delete', $params);
+ $result = $this->callAPIFailure('Event', 'Delete', array());
}
function testDelete() {
$params = array(
'id' => $this->_eventIds[0],
- 'version' => $this->_apiversion,
);
- $result = civicrm_api('Event', 'Delete', $params);
- $this->documentMe($params, $result, __FUNCTION__, __FILE__);
- $this->assertNotEquals($result['is_error'], 1);
+ $result = $this->callAPIAndDocument('Event', 'Delete', $params, __FUNCTION__, __FILE__);
}
- /*
- * check event_id still supported for delete
- */
+
+ /**
+ * check event_id still supported for delete
+ */
function testDeleteWithEventId() {
$params = array(
- 'event_id' => $this->_eventIds[0],
- 'version' => $this->_apiversion,
- );
- $result = civicrm_api('Event', 'Delete', $params);
+ 'event_id' => $this->_eventIds[0], );
+ $result = $this->callAPISuccess('Event', 'Delete', $params);
$this->assertAPISuccess($result, 'in line ' . __LINE__);
}
/*
'eventID' => $this->_eventIds[0],
)
);
- $result = civicrm_api('Event', 'Delete', array('version' => $this->_apiversion, 'id' => $this->_eventIds[0]));
- $this->assertEquals(0, $result['is_error'], "Deleting exist with participants");
+ $result = $this->callAPISuccess('Event', 'Delete', array('id' => $this->_eventIds[0]));
}
function testDeleteWithWrongEventId() {
- $params = array('event_id' => $this->_eventIds[0], 'version' => $this->_apiversion);
- $result = civicrm_api('Event', 'Delete', $params);
+ $params = array('event_id' => $this->_eventIds[0]);
+ $result = $this->callAPISuccess('Event', 'Delete', $params);
// try to delete again - there's no such event anymore
$params = array('event_id' => $this->_eventIds[0]);
$result = $this->callAPIFailure('Event', 'Delete', $params);
* Test civicrm_event_search with empty params
*/
function testSearchEmptyParams() {
- $event = civicrm_api('event', 'create', $this->_params[1]);
+ $event = $this->callAPISuccess('event', 'create', $this->_params[1]);
- $getparams = array(
- 'version' => $this->_apiversion,
- 'sequential' => 1,
+ $getparams = array( 'sequential' => 1,
);
- $result = civicrm_api('event', 'get', $getparams);
+ $result = $this->callAPISuccess('event', 'get', $getparams);
$this->assertEquals($result['count'], 3, 'In line ' . __LINE__);
$res = $result['values'][0];
$this->assertArrayKeyExists('title', $res, 'In line ' . __LINE__);
'event_type_id' => 1,
'return.title' => 1,
'return.id' => 1,
- 'return.start_date' => 1,
- 'version' => $this->_apiversion,
- );
- $result = civicrm_api('event', 'get', $params);
+ 'return.start_date' => 1, );
+ $result = $this->callAPISuccess('event', 'get', $params);
$this->assertEquals($result['values'][$this->_eventIds[0]]['id'], $this->_eventIds[0], 'In line ' . __LINE__);
$this->assertEquals($result['values'][$this->_eventIds[0]]['title'], 'Annual CiviCRM meet', 'In line ' . __LINE__);
$maxEvents = 5;
$events = array();
while ($maxEvents > 0) {
- $params = array(
- 'version' => $this->_apiversion,
- 'title' => 'Test Event' . $maxEvents,
+ $params = array( 'title' => 'Test Event' . $maxEvents,
'event_type_id' => 2,
'start_date' => 20081021,
);
- $events[$maxEvents] = civicrm_api('event', 'create', $params);
+ $events[$maxEvents] = $this->callAPISuccess('event', 'create', $params);
$maxEvents--;
}
- $params = array(
- 'version' => $this->_apiversion,
- 'event_type_id' => 2,
+ $params = array( 'event_type_id' => 2,
'return.id' => 1,
'return.title' => 1,
'return.offset' => 2,
'return.max_results' => 2,
);
- $result = civicrm_api('event', 'get', $params);
+ $result = $this->callAPISuccess('event', 'get', $params);
$this->assertAPISuccess($result);
$this->assertEquals(2, $result['count'], ' 2 results returned In line ' . __LINE__);
}
function testEventCreationPermissions() {
$params = array(
- 'event_type_id' => 1, 'start_date' => '2010-10-03', 'title' => 'le cake is a tie', 'check_permissions' => TRUE,
- 'version' => $this->_apiversion,
- );
+ 'event_type_id' => 1, 'start_date' => '2010-10-03', 'title' => 'le cake is a tie', 'check_permissions' => TRUE, );
$config = &CRM_Core_Config::singleton();
$config->userPermissionClass->permissions = array('access CiviCRM');
$result = $this->callAPIFailure('event', 'create', $params);
$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');
$config->userPermissionClass->permissions = array('access CiviEvent', 'edit all events', 'access CiviCRM');
- $result = civicrm_api('event', 'create', $params);
- $this->assertEquals(0, $result['is_error'], 'overfluous permissions should be enough to create an event');
+ $result = $this->callAPISuccess('event', 'create', $params);
}
function testgetfields() {
$description = "demonstrate use of getfields to interogate api";
- $params = array('version' => 3, 'action' => 'create');
- $result = civicrm_api('event', 'getfields', $params);
+ $params = array('action' => 'create');
+ $result = $this->callAPISuccess('event', 'getfields', $params);
$this->assertEquals(1, $result['values']['title']['api.required'], 'in line ' . __LINE__);
}
/*
*/
function testgetfieldsRest() {
$description = "demonstrate use of getfields to interogate api";
- $params = array('version' => 3, 'api_action' => 'create');
- $result = civicrm_api('event', 'getfields', $params);
+ $params = array('api_action' => 'create');
+ $result = $this->callAPISuccess('event', 'getfields', $params);
$this->assertEquals(1, $result['values']['title']['api.required'], 'in line ' . __LINE__);
}
function testgetfieldsGet() {
$description = "demonstrate use of getfields to interogate api";
- $params = array('version' => 3, 'action' => 'get');
- $result = civicrm_api('event', 'getfields', $params);
+ $params = array('action' => 'get');
+ $result = $this->callAPISuccess('event', 'getfields', $params);
$this->assertEquals('title', $result['values']['event_title']['name'], 'in line ' . __LINE__);
}
function testgetfieldsDelete() {
$description = "demonstrate use of getfields to interogate api";
- $params = array('version' => 3, 'action' => 'delete');
- $result = civicrm_api('event', 'getfields', $params);
+ $params = array('action' => 'delete');
+ $result = $this->callAPISuccess('event', 'getfields', $params);
$this->assertEquals(1, $result['values']['id']['api.required']);
}
}
parent::setUp();
$this->ids['contact'][0] = $this->individualCreate();
$this->params = array(
- 'version' => 3,
- 'contact_id' => $this->ids['contact'][0],
+ 'contact_id' => $this->ids['contact'][0],
'application_received_date' => 'now',
'decision_date' => 'next Monday',
'amount_total' => '500',
function tearDown() {
foreach ($this->ids as $entity => $entities) {
foreach ($entities as $id) {
- civicrm_api($entity, 'delete', array('version' => $this->_apiversion, 'id' => $id));
+ $this->callAPISuccess($entity, 'delete', array( 'id' => $id));
}
}
}
public function testCreateGrant() {
- $result = civicrm_api($this->_entity, 'create', $this->params);
- $this->documentMe($this->params, $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
+ $result = $this->callAPIAndDocument($this->_entity, 'create', $this->params, __FUNCTION__, __FILE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
$this->getAndCheck($this->params, $result['id'], $this->_entity);
}
public function testGetGrant() {
- $result = civicrm_api($this->_entity, 'create', $this->params);
+ $result = $this->callAPISuccess($this->_entity, 'create', $this->params);
$this->ids['grant'][0] = $result['id'];
- $result = civicrm_api($this->_entity, 'get', array('version' => $this->_apiversion, 'rationale' => 'Just Because'));
- $this->documentMe($this->params, $result, __FUNCTION__, __FILE__);
+ $result = $this->callAPIAndDocument($this->_entity, 'get', array('rationale' => 'Just Because'), __FUNCTION__, __FILE__);
$this->assertAPISuccess($result, 'In line ' . __LINE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
}
public function testDeleteGrant() {
- $result = civicrm_api($this->_entity, 'create', $this->params);
- $result = civicrm_api($this->_entity, 'delete', array('version' => 3, 'id' => $result['id']));
- $this->documentMe($this->params, $result, __FUNCTION__, __FILE__);
+ $result = $this->callAPISuccess($this->_entity, 'create', $this->params);
+ $result = $this->callAPIAndDocument($this->_entity, 'delete', array('id' => $result['id']), __FUNCTION__, __FILE__);
$this->assertAPISuccess($result, 'In line ' . __LINE__);
- $checkDeleted = civicrm_api($this->_entity, 'get', array(
- 'version' => 3,
- ));
+ $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array(
+ ));
$this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__);
}
/*
public function testCreateAutoGrant() {
$entityName = $this->_entity;
$baoString = 'CRM_Grant_BAO_Grant';
- $fields = civicrm_api($entityName, 'getfields', array(
- 'version' => 3,
- 'action' => 'create',
+ $fields = $this->callAPISuccess($entityName, 'getfields', array(
+ 'action' => 'create',
)
);
$return = array_keys($fields);
$baoObj = new CRM_Core_DAO();
$baoObj->createTestObject($baoString, array('currency' => 'USD'), 2, 0);
- $getentities = civicrm_api($entityName, 'get', array(
- 'version' => 3,
- 'sequential' => 1,
+ $getentities = $this->callAPISuccess($entityName, 'get', array(
+ 'sequential' => 1,
'return' => $return,
));
$entity[$field] = 'warm.beer.com';
}
$updateParams = array(
- 'version' => 3,
- 'id' => $entity['id'],
+ 'id' => $entity['id'],
$field => $entity[$field],
'debug' => 1,
);
- $update = civicrm_api($entityName, 'create', $updateParams);
+ $update = $this->callAPISuccess($entityName, 'create', $updateParams);
$this->assertAPISuccess($update, "setting $field to {$entity[$field]} in line " . __LINE__);
$checkParams = array(
'id' => $entity['id'],
- 'version' => 3,
'sequential' => 1,
);
- $checkEntity = civicrm_api($entityName, 'getsingle', $checkParams);
- $this->assertEquals($entity, $checkEntity, "changing field $field");
+ $checkEntity = $this->callAPISuccess($entityName, 'getsingle', $checkParams);
+ $this->assertAPIArrayComparison((array) $entity, $checkEntity);
}
$baoObj->deleteTestObjects($baoString);
$baoObj->free();
'location_type_id' => $this->_locationType,
'phone' => '(123) 456-7890',
'is_primary' => 1,
- 'version' => $this->_apiversion,
'phone_type_id' => 1,
);
}
public function testCreatePhone() {
- $result = civicrm_api('phone', 'create', $this->_params);
-
- $this->documentMe($this->_params, $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
+ $result = $this->callAPIAndDocument('phone', 'create', $this->_params, __FUNCTION__, __FILE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
- // $this->assertEquals( 1, $result['id'], 'In line ' . __LINE__ );
-
- $delresult = civicrm_api('phone', 'delete', array('id' => $result['id'], 'version' => $this->_apiversion));
- $this->assertEquals(0, $delresult['is_error'], 'In line ' . __LINE__);
+ $this->callAPISuccess('phone', 'delete', array('id' => $result['id']));
}
public function testDeletePhone() {
//create one
- $create = civicrm_api('phone', 'create', $this->_params);
-
- $this->assertAPISuccess($create, 'In line ' . __LINE__);
+ $create = $this->callAPISuccess('phone', 'create', $this->_params);
- $result = civicrm_api('phone', 'delete', array('id' => $create['id'], 'version' => $this->_apiversion));
- $this->documentMe($this->_params, $result, __FUNCTION__, __FILE__);
- $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__);
+ $result = $this->callAPIAndDocument('phone', 'delete', array('id' => $create['id'],), __FUNCTION__, __FILE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
- $get = civicrm_api('phone', 'get', array(
- 'version' => $this->_apiversion, 'id' => $create['id'],
- 'location_type_id' => $this->_locationType,
- ));
- $this->assertEquals(0, $get['is_error'], 'In line ' . __LINE__);
+ $get = $this->callAPISuccess('phone', 'get', array(
+ 'id' => $create['id'],
+ 'location_type_id' => $this->_locationType,
+ ));
$this->assertEquals(0, $get['count'], 'Phone not successfully deleted In line ' . __LINE__);
}
- /**
- * Test civicrm_phone_get with wrong params type.
- */
- public function testGetWrongParamsType() {
- $params = 'is_string';
- $result = civicrm_api('Phone', 'Get', ($params));
- $this->assertEquals(1, $result['is_error'], 'In line ' . __LINE__);
- }
-
/**
* Test civicrm_phone_get with empty params.
*/
public function testGetEmptyParams() {
- $params = array('version' => $this->_apiversion);
- $result = civicrm_api('Phone', 'Get', ($params));
- $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__);
+ $result = $this->callAPISuccess('Phone', 'Get', array());
}
/**
*/
public function testGetWrongParams() {
$this->callAPIFailure('Phone', 'Get', array('contact_id' => 'abc'));
-
$this->callAPIFailure('Phone', 'Get', array('location_type_id' => 'abc'));
-
$this->callAPIFailure('Phone', 'Get', array('phone_type_id' => 'abc'));
}
$params = array(
'contact_id' => $this->_params['contact_id'],
'phone' => $phone['values'][$phone['id']]['phone'],
- 'version' => $this->_apiversion,
);
- $result = civicrm_api('Phone', 'Get', ($params));
- $this->documentMe($params, $result, __FUNCTION__, __FILE__);
- $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__);
+ $result = $this->callAPIAndDocument('Phone', 'Get', $params, __FUNCTION__, __FILE__);
$this->assertEquals($phone['values'][$phone['id']]['location_type_id'], $result['values'][$phone['id']]['location_type_id'], 'In line ' . __LINE__);
$this->assertEquals($phone['values'][$phone['id']]['phone_type_id'], $result['values'][$phone['id']]['phone_type_id'], 'In line ' . __LINE__);
$this->assertEquals($phone['values'][$phone['id']]['is_primary'], $result['values'][$phone['id']]['is_primary'], 'In line ' . __LINE__);
///////////////// civicrm_phone_create methods
- /**
- * Test civicrm_phone_create with wrong params type.
- */
- public function testCreateWrongParamsType() {
- $params = 'a string';
- $result = $this->callAPIFailure('Phone', 'Create', $params);
- }
-
/**
* Ensure numeric_phone field is correctly populated (this happens via sql trigger)
*/
public function testNumericPhone() {
- $result = civicrm_api('phone', 'create', $this->_params);
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
+ $result = $this->callAPISuccess('phone', 'create', $this->_params);
$id = $result['id'];
- $params = array('id' => $id, 'version' => $this->_apiversion, 'return.phone_numeric' => 1);
- $result = civicrm_api('phone', 'get', $params);
+ $params = array('id' => $id, 'return.phone_numeric' => 1);
+ $result = $this->callAPISuccess('phone', 'get', $params);
$this->assertEquals('1234567890', $result['values'][$id]['phone_numeric']);
}
public function testCreatePhonePrimaryHandlingChangeToPrimary() {
$params = $this->_params;
unset($params['is_primary']);
- $phone1 = civicrm_api('phone', 'create', $params);
- $this->assertApiSuccess($phone1, 'In line ' . __LINE__);
+ $phone1 = $this->callAPISuccess('phone', 'create', $params);
//now we check & make sure it has been set to primary
- $check = civicrm_api('phone', 'getcount', array(
- 'version' => 3,
+ $check = $this->callAPISuccess('phone', 'getcount', array(
'is_primary' => 1,
'id' => $phone1['id'],
));
$this->assertEquals(1, $check);
}
public function testCreatePhonePrimaryHandlingChangeExisting() {
- $phone1 = civicrm_api('phone', 'create', $this->_params);
- $this->assertApiSuccess($phone1, 'In line ' . __LINE__);
- $phone2 = civicrm_api('phone', 'create', $this->_params);
- $this->assertApiSuccess($phone2, 'In line ' . __LINE__);
- $check = civicrm_api('phone', 'getcount', array(
- 'version' => 3,
- 'is_primary' => 1,
- 'contact_id' => $this->_contactID,
- ));
+ $phone1 = $this->callAPISuccess('phone', 'create', $this->_params);
+ $phone2 = $this->callAPISuccess('phone', 'create', $this->_params);
+ $check = $this->callAPISuccess('phone', 'getcount', array(
+ 'is_primary' => 1,
+ 'contact_id' => $this->_contactID,
+ ));
$this->assertEquals(1, $check);
}
}
parent::setUp();
// put stuff here that should happen before all tests in this unit
$priceSetparams = array(
- 'version' => 3,
# [domain_id] =>
'name' => 'default_goat_priceset',
'title' => 'Goat accomodation',
'is_reserved' => 1,
);
- $price_set = civicrm_api('price_set', 'create',$priceSetparams);
+ $price_set = $this->callAPISuccess('price_set', 'create',$priceSetparams);
$this->priceSetID = $price_set['id'];
$priceFieldparams = array(
- 'version' => $this->_apiversion,
'price_set_id' => $this->priceSetID,
'name' => 'grassvariety',
'label' => 'Grass Variety',
'is_enter_qty' => 1,
'is_active' => 1,
);
- $priceField = civicrm_api('price_field','create', $priceFieldparams);
+ $priceField = $this->callAPISuccess('price_field','create', $priceFieldparams);
$this->priceFieldID = $priceField['id'];
$this->_params = array(
- 'version' => 3,
'price_field_id' => $this->priceFieldID,
'name' => 'ryegrass',
'label' => 'juicy and healthy',
$membershipOrgId = $this->organizationCreate(NULL);
$this->_membershipTypeID = $this->membershipTypeCreate($membershipOrgId);
$priceSetparams1 = array(
- 'version' => $this->_apiversion,
'name' => 'priceset',
'title' => 'Priceset with Multiple Terms',
'is_active' => 1,
'is_quick_config' => 1,
'is_reserved' => 1,
);
- $price_set1 = civicrm_api('price_set', 'create',$priceSetparams1);
+ $price_set1 = $this->callAPISuccess('price_set', 'create',$priceSetparams1);
$this->priceSetID1 = $price_set1['id'];
$priceFieldparams1 = array(
- 'version' => $this->_apiversion,
'price_set_id' => $this->priceSetID1,
'name' => 'memtype',
'label' => 'memtype',
'is_enter_qty' => 1,
'is_active' => 1,
);
- $priceField1 = civicrm_api('price_field','create', $priceFieldparams1);
+ $priceField1 = $this->callAPISuccess('price_field','create', $priceFieldparams1);
$this->priceFieldID1 = $priceField1['id'];
}
);
$this->quickCleanup($tablesToTruncate);
$this->membershipTypeDelete(array('id' => $this->_membershipTypeID));
- civicrm_api('PriceField','delete', array(
- 'version' => 3,
+ $this->callAPISuccess('PriceField','delete', array(
'id' => $this->priceFieldID1,
));
- civicrm_api('PriceSet','delete', array(
- 'version' => 3,
+ $this->callAPISuccess('PriceSet','delete', array(
'id' => $this->priceSetID1,
));
- civicrm_api('PriceField','delete', array(
- 'version' => 3,
+ $this->callAPISuccess('PriceField','delete', array(
'id' => $this->priceFieldID,
));
- $delete = civicrm_api('PriceSet','delete', array(
- 'version' => 3,
+ $delete = $this->callAPISuccess('PriceSet','delete', array(
'id' => $this->priceSetID,
));
}
public function testCreatePriceFieldValue() {
- $result = civicrm_api($this->_entity, 'create', $this->_params);
- $this->id = $result['id'];
- $this->documentMe($this->_params, $result, __FUNCTION__, __FILE__);
+ $result = $this->callAPIAndDocument($this->_entity, 'create', $this->_params, __FUNCTION__, __FILE__);
$this->assertAPISuccess($result, 'In line ' . __LINE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
}
public function testGetBasicPriceFieldValue() {
- $createResult = civicrm_api($this->_entity, 'create', $this->_params);
+ $createResult = $this->callAPISuccess($this->_entity, 'create', $this->_params);
$this->id = $createResult['id'];
$this->assertAPISuccess($createResult);
$getParams = array(
- 'version' => $this->_apiversion,
'name' => 'contribution_amount',
);
- $getResult = civicrm_api($this->_entity, 'get', $getParams);
- $this->documentMe($getParams, $getResult, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($getResult, 'In line ' . __LINE__);
+ $getResult = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__);
$this->assertEquals(1, $getResult['count'], 'In line ' . __LINE__);
- civicrm_api('price_field_value','delete', array('version' => 3, 'id' => $createResult['id']));
+ $this->callAPISuccess('price_field_value','delete', array('id' => $createResult['id']));
}
public function testDeletePriceFieldValue() {
- $startCount = civicrm_api($this->_entity, 'getcount', array(
- 'version' => $this->_apiversion,
- ));
- $createResult = civicrm_api($this->_entity, 'create', $this->_params);
- $deleteParams = array('version' => $this->_apiversion, 'id' => $createResult['id']);
- $deleteResult = civicrm_api($this->_entity, 'delete', $deleteParams);
- $this->documentMe($deleteParams, $deleteResult, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($deleteResult, 'In line ' . __LINE__);
- $endCount = civicrm_api($this->_entity, 'getcount', array(
- 'version' => $this->_apiversion,
- ));
+ $startCount = $this->callAPISuccess($this->_entity, 'getcount', array());
+ $createResult = $this->callAPISuccess($this->_entity, 'create', $this->_params);
+ $deleteParams = array('id' => $createResult['id']);
+ $deleteResult = $this->callAPIAndDocument($this->_entity, 'delete', $deleteParams, __FUNCTION__, __FILE__);
+
+ $endCount = $this->callAPISuccess($this->_entity, 'getcount', array());
$this->assertEquals($startCount, $endCount, 'In line ' . __LINE__);
}
public function testGetFieldsPriceFieldValue() {
- $result = civicrm_api($this->_entity, 'getfields', array('version' => $this->_apiversion, 'action' => 'create'));
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
+ $result = $this->callAPISuccess($this->_entity, 'getfields', array('action' => 'create'));
$this->assertEquals(1, $result['values']['max_value']['type']);
}
public function testCreatePriceFieldValuewithMultipleTerms() {
$params = array(
- 'version' => 3,
'price_field_id' => $this->priceFieldID1,
'membership_type_id' => $this->_membershipTypeID,
'name' => 'memType1',
'is_active' => 1,
'financial_type_id' => 2,
);
- $result = civicrm_api($this->_entity, 'create', $params);
- $this->documentMe($params, $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
+ $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($result['values'][$result['id']]['membership_num_terms'], 2);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
- civicrm_api($this->_entity, 'delete', array('version' => 3, 'id' => $result['id']));
+ $this->callAPISuccess($this->_entity, 'delete', array('id' => $result['id']));
}
public function testGetPriceFieldValuewithMultipleTerms() {
$params1 = array(
- 'version' => 3,
'price_field_id' => $this->priceFieldID1,
'membership_type_id' => $this->_membershipTypeID,
'name' => 'memType1',
'financial_type_id' => 2,
);
$params2 = array(
- 'version' => 3,
'price_field_id' => $this->priceFieldID1,
'membership_type_id' => $this->_membershipTypeID,
'name' => 'memType2',
'is_active' => 1,
'financial_type_id' => 2,
);
- $result1 = civicrm_api($this->_entity, 'create', $params1);
- $result2 = civicrm_api($this->_entity, 'create', $params2);
- $result = civicrm_api($this->_entity, 'get', array( 'version' => 3, 'price_field_id' =>$this->priceFieldID1 ));
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
+ $result1 = $this->callAPISuccess($this->_entity, 'create', $params1);
+ $result2 = $this->callAPISuccess($this->_entity, 'create', $params2);
+ $result = $this->callAPISuccess($this->_entity, 'get', array('price_field_id' =>$this->priceFieldID1 ));
$this->assertEquals(2, $result['count'], 'In line ' . __LINE__);
- civicrm_api($this->_entity,'delete', array('version' => 3, 'id' => $result1['id']));
- civicrm_api($this->_entity,'delete', array('version' => 3, 'id' => $result2['id']));
+ $this->callAPISuccess($this->_entity,'delete', array('id' => $result1['id']));
+ $this->callAPISuccess($this->_entity,'delete', array('id' => $result2['id']));
}
}
public function setUp() {
parent::setUp();
$this->_params = array(
- 'version' => $this->_apiversion,
# [domain_id] =>
'name' => 'default_goat_priceset',
'title' => 'Goat accessories',
}
public function testCreatePriceSet() {
- $result = civicrm_api($this->_entity, 'create', $this->_params);
- $this->id = $result['id'];
- $this->documentMe($this->_params, $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
+ $result = $this->callAPIAndDocument($this->_entity, 'create', $this->_params, __FUNCTION__, __FILE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
$this->getAndCheck($this->_params, $result['id'], $this->_entity);
public function testGetBasicPriceSet() {
$getParams = array(
- 'version' => $this->_apiversion,
'name' => 'default_contribution_amount',
);
- $getResult = civicrm_api($this->_entity, 'get', $getParams);
- $this->documentMe($getParams, $getResult, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($getResult, 'In line ' . __LINE__);
+ $getResult = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__);
$this->assertEquals(1, $getResult['count'], 'In line ' . __LINE__);
}
public function testEventPriceSet() {
- $event = civicrm_api('event', 'create', array(
- 'version' => $this->_apiversion,
+ $event = $this->callAPISuccess('event', 'create', array(
'title' => 'Event with Price Set',
'event_type_id' => 1,
'is_public' => 1,
'end_date' => 20151023,
'is_active' => 1,
));
- $this->assertAPISuccess($event);
$createParams = array(
- 'version' => $this->_apiversion,
'entity_table' => 'civicrm_event',
'entity_id' => $event['id'],
'name' => 'event price',
'title' => 'event price',
'extends' => 1,
);
- $createResult = civicrm_api($this->_entity, 'create', $createParams);
- $this->documentMe($createParams, $createResult, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($createResult, 'In line ' . __LINE__);
- $id = $createResult['id'];
- $result = civicrm_api($this->_entity, 'get', array(
- 'version' => $this->_apiversion,
- 'id' => $id,
+ $createResult = $this->callAPIAndDocument($this->_entity, 'create', $createParams, __FUNCTION__, __FILE__);
+ $result = $this->callAPISuccess($this->_entity, 'get', array(
+ 'id' => $createResult['id'],
));
- $this->assertEquals(array('civicrm_event' => array($event['id'])), $result['values'][$id]['entity'], 'In line ' . __LINE__);
+ $this->assertEquals(array('civicrm_event' => array($event['id'])), $result['values'][$createResult['id']]['entity'], 'In line ' . __LINE__);
}
public function testDeletePriceSet() {
- $startCount = civicrm_api($this->_entity, 'getcount', array(
- 'version' => $this->_apiversion,
- ));
- $createResult = civicrm_api($this->_entity, 'create', $this->_params);
- $deleteParams = array('version' => $this->_apiversion, 'id' => $createResult['id']);
- $deleteResult = civicrm_api($this->_entity, 'delete', $deleteParams);
- $this->documentMe($deleteParams, $deleteResult, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($deleteResult, 'In line ' . __LINE__);
- $endCount = civicrm_api($this->_entity, 'getcount', array(
- 'version' => $this->_apiversion,
- ));
+ $startCount = $this->callAPISuccess($this->_entity, 'getcount', array());
+ $createResult = $this->callAPISuccess($this->_entity, 'create', $this->_params);
+ $deleteParams = array('id' => $createResult['id']);
+ $deleteResult = $this->callAPIAndDocument($this->_entity, 'delete', $deleteParams, __FUNCTION__, __FILE__);
+ $endCount = $this->callAPISuccess($this->_entity, 'getcount', array());
$this->assertEquals($startCount, $endCount, 'In line ' . __LINE__);
}
public function testGetFieldsPriceSet() {
- $result = civicrm_api($this->_entity, 'getfields', array('version' => $this->_apiversion, 'action' => 'create'));
- $this->assertAPISuccess($result, 'In line ' . __LINE__);
+ $result = $this->callAPISuccess($this->_entity, 'getfields', array('action' => 'create'));
$this->assertEquals(16, $result['values']['is_quick_config']['type']);
}
<?php
-
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.3 |
* @package CiviCRM
*/
class api_v3_UtilsTest extends CiviUnitTestCase {
- protected $_apiversion;
+ protected $_apiversion = 3;
public $DBResetRequired = FALSE;
public $_eNoticeCompliant = TRUE;
public $_contactID = 1;
*/
protected function setUp() {
parent::setUp();
- $this->_apiversion = 3;
}
/**
'contact_id' => $this->_contactID,
'modified_date' => '2011-01-31',
'subject' => NULL,
- 'version' => $this->_apiversion,
+ 'version' => $this->_apiversion
);
try {
$result = civicrm_api3_verify_mandatory($params, 'CRM_Core_BAO_Note', array('note', 'subject'));
*/
function testVerifyOneMandatoryOneSet() {
_civicrm_api3_initialize(TRUE);
- $params = array('entity_table' => 'civicrm_contact', 'note' => 'note', 'contact_id' => $this->_contactID, 'modified_date' => '2011-01-31', 'subject' => NULL, 'version' => $this->_apiversion);
+ $params = array('version' => 3, 'entity_table' => 'civicrm_contact', 'note' => 'note', 'contact_id' => $this->_contactID, 'modified_date' => '2011-01-31', 'subject' => NULL);
try {
civicrm_api3_verify_one_mandatory($params, NULL, array('note', 'subject'));
}
function testGetFields() {
- $result = civicrm_api('membership', 'getfields', array('version' => 3));
+ $result = $this->callAPISuccess('membership', 'getfields', array());
$this->assertArrayHasKey('values', $result);
- $result = civicrm_api('relationship', 'getfields', array('version' => 3));
+ $result = $this->callAPISuccess('relationship', 'getfields', array());
$this->assertArrayHasKey('values', $result);
- $result = civicrm_api('event', 'getfields', array('version' => 3));
+ $result = $this->callAPISuccess('event', 'getfields', array());
$this->assertArrayHasKey('values', $result);
}
function testGetFields_AllOptions() {
- $result = civicrm_api('contact', 'getfields', array(
+ $result = $this->callAPISuccess('contact', 'getfields', array(
'options' => array(
'get_options' => 'all',
),
- 'version' => 3
));
- $this->assertAPISuccess($result);
$this->assertEquals('Household', $result['values']['contact_type']['options']['Household']);
$this->assertEquals('HTML', $result['values']['preferred_mail_format']['options']['HTML']);
}