$this->_participantID = $this->participantCreate(array('contact_id' => $this->_contactID, 'event_id' => $this->_eventID));
$this->_contactID2 = $this->individualCreate(NULL);
- $this->_participantID2 = $this->participantCreate(array('contact_id' => $this->_contactID2, 'event_id' => $this->_eventID, 'version' => $this->_apiversion));
- $this->_participantID3 = $this->participantCreate(array('contact_id' => $this->_contactID2, 'event_id' => $this->_eventID, 'version' => $this->_apiversion));
+ $this->_participantID2 = $this->participantCreate(array('contact_id' => $this->_contactID2, 'event_id' => $this->_eventID));
+ $this->_participantID3 = $this->participantCreate(array('contact_id' => $this->_contactID2, 'event_id' => $this->_eventID));
$this->_params = array(
'contact_id' => $this->_contactID,
'event_id' => $this->_eventID,
// to ensure it matches later on
'register_date' => '2007-07-21 00:00:00',
'source' => 'Online Event Registration: API Testing',
- 'version' => $this->_apiversion,
);
}
$params = $this->_params;
$params['custom_' . $ids['custom_field_id']] = "custom string";
- $result = civicrm_api($this->_entity, 'create', $params);
+ $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
+
$this->assertEquals($result['id'], $result['values'][$result['id']]['id']);
- $this->documentMe($params, $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result);
- $check = civicrm_api($this->_entity, 'get', array('version' => 3, 'id' => $result['id']));
+ $check = $this->callAPISuccess($this->_entity, 'get', array('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']);
function testGetParticipantIdOnly() {
$params = array(
'participant_id' => $this->_participantID,
- 'version' => $this->_apiversion,
'return' => array(
'participant_id',
'event_id',
'participant_source',
)
);
- $result = civicrm_api('participant', 'get', $params);
+ $result = $this->callAPISuccess('participant', 'get', $params);
$this->assertAPISuccess($result, " in line " . __LINE__);
$this->assertEquals($result['values'][$this->_participantID]['event_id'], $this->_eventID, "in line " . __LINE__);
$this->assertEquals($result['values'][$this->_participantID]['participant_register_date'], '2007-02-19 00:00:00', "in line " . __LINE__);
$this->assertEquals($result['values'][$this->_participantID]['participant_source'], 'Wimbeldon', "in line " . __LINE__);
$params = array(
'id' => $this->_participantID,
- 'version' => $this->_apiversion,
'return' => 'id,participant_register_date,event_id',
);
- $result = civicrm_api('participant', 'get', $params);
+ $result = $this->callAPISuccess('participant', 'get', $params);
$this->assertEquals($result['values'][$this->_participantID]['event_id'], $this->_eventID);
$this->assertEquals($result['values'][$this->_participantID]['participant_register_date'], '2007-02-19 00:00:00');
function testGetParamsAsIdOnly() {
$params = array(
'id' => $this->_participantID,
- 'version' => $this->_apiversion,
);
- $result = civicrm_api('participant', 'get', $params);
- $this->documentMe($params, $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result);
+ $result = $this->callAPIAndDocument('participant', 'get', $params, __FUNCTION__, __FILE__);
$this->assertEquals($result['values'][$this->_participantID]['event_id'], $this->_eventID);
$this->assertEquals($result['values'][$this->_participantID]['participant_register_date'], '2007-02-19 00:00:00');
$this->assertEquals($result['values'][$this->_participantID]['participant_source'], 'Wimbeldon');
function testGetNestedEventGet() {
//create a second event & add participant to it.
$event = $this->eventCreate(NULL);
- civicrm_api('participant', 'create', array('version' => 3, 'event_id' => $event['id'], 'contact_id' => $this->_contactID));
+ $this->callAPISuccess('participant', 'create', array('event_id' => $event['id'], 'contact_id' => $this->_contactID));
$description = "use nested get to get an event";
$subfile = "NestedEventGet";
$params = array(
'id' => $this->_participantID,
- 'version' => $this->_apiversion,
'api.event.get' => 1,
);
- $result = civicrm_api('participant', 'get', $params);
- $this->documentMe($params, $result, __FUNCTION__, __FILE__, $description, $subfile);
- $this->assertAPISuccess($result);
+ $result = $this->callAPIAndDocument('participant', 'get', $params, __FUNCTION__, __FILE__, $description, $subfile);
$this->assertEquals($result['values'][$this->_participantID]['event_id'], $this->_eventID);
$this->assertEquals($result['values'][$this->_participantID]['participant_register_date'], '2007-02-19 00:00:00');
$this->assertEquals($result['values'][$this->_participantID]['participant_source'], 'Wimbeldon');
*/
function testGetWithReturnProperties() {
$params = array(
- 'contact_id' => $this->_contactID,
- 'version' => $this->_apiversion,
- 'return.status_id' => 1,
+ 'contact_id' => $this->_contactID, 'return.status_id' => 1,
'return.participant_status_id' => 1,
'options' => array('limit' => 1)
);
- $result = civicrm_api('participant', 'get', $params);
+ $result = $this->callAPISuccess('participant', 'get', $params);
$this->assertArrayHasKey('participant_status_id', $result['values'][$result['id']]);
}
*/
function testGetContactIdOnly() {
$params = array(
- 'contact_id' => $this->_contactID,
- 'version' => $this->_apiversion,
- );
- $participant = civicrm_api('participant', 'get', $params);
+ 'contact_id' => $this->_contactID, );
+ $participant = $this->callAPISuccess('participant', 'get', $params);
$this->assertEquals($this->_participantID, $participant['id'],
"In line " . __LINE__
function testGetMultiMatchReturnFirst() {
$params = array(
'event_id' => $this->_eventID,
- 'rowCount' => 1,
- 'version' => $this->_apiversion,
- );
+ 'rowCount' => 1, );
- $participant = civicrm_api('participant', 'get', $params);
+ $participant = $this->callAPISuccess('participant', 'get', $params);
$this->assertNotNull($participant['id']);
}
function testGetMultiMatchNoReturnFirst() {
$params = array(
'event_id' => $this->_eventID,
- 'version' => $this->_apiversion,
);
- $participant = civicrm_api('participant', 'get', $params);
- $this->assertEquals($participant['is_error'], 0);
+ $participant = $this->callAPISuccess('participant', 'get', $params);
$this->assertNotNull($participant['count'], 3);
}
///////////////// civicrm_participant_get methods
- /**
- * Test civicrm_participant_get with wrong params type
- */
- function testSearchWrongParamsType() {
- $params = 'a string';
- $result = $this->callAPIFailure('participant', 'get', $params);
- }
-
/**
* Test civicrm_participant_get with empty params
* In this case all the participant records are returned.
*/
function testSearchEmptyParams() {
- $params = array('version' => $this->_apiversion);
- $result = civicrm_api('participant', 'get', $params);
-
+ $result = $this->callAPISuccess('participant', 'get', array());
// expecting 3 participant records
$this->assertEquals($result['count'], 3);
}
function testSearchParticipantIdOnly() {
$params = array(
'participant_id' => $this->_participantID,
- 'version' => $this->_apiversion,
);
- $participant = civicrm_api('participant', 'get', $params);
+ $participant = $this->callAPISuccess('participant', 'get', $params);
$this->assertEquals($participant['values'][$this->_participantID]['event_id'], $this->_eventID);
$this->assertEquals($participant['values'][$this->_participantID]['participant_register_date'], '2007-02-19 00:00:00');
$this->assertEquals($participant['values'][$this->_participantID]['participant_source'], 'Wimbeldon');
// Should get 2 participant records for this contact.
$params = array(
'contact_id' => $this->_contactID2,
- 'version' => $this->_apiversion,
);
- $participant = civicrm_api('participant', 'get', $params);
+ $participant = $this->callAPISuccess('participant', 'get', $params);
$this->assertEquals($participant['count'], 2);
}
'event_id' => $this->_eventID,
'return.last_name' => 1,
'return.event_title' => 1,
- 'version' => $this->_apiversion,
);
- $participant = civicrm_api('participant', 'get', $params);
+ $participant = $this->callAPISuccess('participant', 'get', $params);
if ($participant['count'] < 3) {
$this->fail("Event search returned less than expected miniumum of 3 records.");
}
$params = array(
'event_id' => $this->_eventID,
'rowCount' => 2,
- 'version' => $this->_apiversion,
);
- $participant = civicrm_api('participant', 'get', $params);
+ $participant = $this->callAPISuccess('participant', 'get', $params);
$this->assertEquals($participant['count'], 2, 'in line ' . __LINE__);
}
///////////////// civicrm_participant_create methods
- /**
- * Test civicrm_participant_create with wrong params type
- */
- function testCreateWrongParamsType() {
- $params = 'a string';
- $result = $this->callAPIFailure('participant', 'create', $params);
- }
-
/**
* Test civicrm_participant_create with empty params
*/
function testCreateMissingContactID() {
$params = array(
'event_id' => $this->_eventID,
- 'version' => $this->_apiversion,
);
- $participant = civicrm_api('participant', 'create', $params);
- if (CRM_Utils_Array::value('id', $participant)) {
- $this->_createdParticipants[] = $participant['id'];
- }
- $this->assertEquals($participant['is_error'], 1);
- $this->assertNotNull($participant['error_message']);
+ $participant = $this->callAPIFailure('participant', 'create', $params);
}
/**
function testCreateMissingEventID() {
$params = array(
'contact_id' => $this->_contactID,
- 'version' => $this->_apiversion,
);
- $participant = civicrm_api('participant', 'create', $params);
- if (CRM_Utils_Array::value('id', $participant)) {
- $this->_createdParticipants[] = $participant['id'];
- }
- $this->assertEquals($participant['is_error'], 1);
- $this->assertNotNull($participant['error_message']);
+ $participant = $this->callAPIFailure('participant', 'create', $params);
}
/**
$params = array(
'contact_id' => $this->_contactID,
'event_id' => $this->_eventID,
- 'version' => $this->_apiversion,
);
- $participant = civicrm_api('participant', 'create', $params);
- $this->assertAPISuccess($participant);
- $this->_participantID = $participant['id'];
-
- if (!$participant['is_error']) {
- // assertDBState compares expected values in $match to actual values in the DB
- unset($params['version']);
- $this->assertDBState('CRM_Event_DAO_Participant', $participant['id'], $params);
- }
+ $participant = $this->callAPISuccess('participant', 'create', $params);
+ $this->getAndCheck($params, $participant['id'], 'participant');
}
/**
function testCreateAllParams() {
$params = $this->_params;
- $participant = civicrm_api('participant', 'create', $params);
- $this->assertNotEquals($participant['is_error'], 1, 'in line ' . __LINE__);
+ $participant = $this->callAPISuccess('participant', 'create', $params);
$this->_participantID = $participant['id'];
- if (!$participant['is_error']) {
- // assertDBState compares expected values in $match to actual values in the DB
- unset($params['version']);
- $this->assertDBState('CRM_Event_DAO_Participant', $participant['id'], $params);
- }
+ // assertDBState compares expected values in $match to actual values in the DB
+ $this->assertDBState('CRM_Event_DAO_Participant', $participant['id'], $params);
}
/*
* Test to check if receive date is being changed per CRM-9763
*/
function testCreateUpdateReceiveDate() {
- $participant = civicrm_api('participant', 'create', $this->_params);
+ $participant = $this->callAPISuccess('participant', 'create', $this->_params);
$update = array(
- 'version' => 3,
- 'id' => $participant['id'],
+ 'id' => $participant['id'],
'status_id' => 2,
);
- civicrm_api('participant', 'create', $update);
+ $this->callAPISuccess('participant', 'create', $update);
$this->getAndCheck(array_merge($this->_params, $update), $participant['id'], 'participant');
}
/*
*/
function testCreateUpdateParticipantFeeLevel() {
$myParams = $this->_params + array('participant_fee_level' => CRM_Core_DAO::VALUE_SEPARATOR . "fee" . CRM_Core_DAO::VALUE_SEPARATOR);
- $participant = civicrm_api('participant', 'create', $myParams);
+ $participant = $this->callAPISuccess('participant', 'create', $myParams);
$this->assertAPISuccess($participant);
$update = array(
- 'version' => 3,
- 'id' => $participant['id'],
+ 'id' => $participant['id'],
'status_id' => 2,
);
- civicrm_api('participant', 'create', $update);
+ $this->callAPISuccess('participant', 'create', $update);
$this->assertEquals($participant['values'][$participant['id']]['participant_fee_level'],
$update['values'][$participant['id']]['participant_fee_level']
);
- civicrm_api('participant', 'delete', array('version' => 3, 'id' => $participant['id']));
+ $this->callAPISuccess('participant', 'delete', array('id' => $participant['id']));
}
- /*
- * Test to check if participant fee level is being changed per CRM-9781
- * Try again without a custom separater to check that one isn't added
- * (get & check won't accept an array)
- */
+ /**
+ * check with complete array
+ */
+ function testUpdate() {
+ $participantId = $this->participantCreate(array('contactID' => $this->_individualId, 'eventID' => $this->_eventID, $this->_apiversion));
+ $params = array(
+ 'id' => $participantId,
+ 'contact_id' => $this->_individualId,
+ 'event_id' => $this->_eventID,
+ 'status_id' => 3,
+ 'role_id' => 3,
+ 'register_date' => '2006-01-21',
+ 'source' => 'US Open',
+ 'event_level' => 'Donation',
+ );
+ $participant = $this->callAPISuccess('participant', 'create', $params);
+ $this->getAndCheck($params, $participant['id'], 'participant');
+ $result = $this->participantDelete($params['id']);
+ }
+
+ /**
+ * Test to check if participant fee level is being changed per CRM-9781
+ * Try again without a custom separater to check that one isn't added
+ * (get & check won't accept an array)
+ */
function testUpdateCreateParticipantFeeLevelNoSeparator() {
$myParams = $this->_params + array('participant_fee_level' => "fee");
- $participant = civicrm_api('participant', 'create', $myParams);
+ $participant = $this->callAPISuccess('participant', 'create', $myParams);
$this->assertAPISuccess($participant);
$update = array(
- 'version' => 3,
- 'id' => $participant['id'],
+ 'id' => $participant['id'],
'status_id' => 2,
);
- civicrm_api('participant', 'create', $update);
+ $this->callAPISuccess('participant', 'create', $update);
$this->assertEquals($participant['values'][$participant['id']]['fee_level'],
$myParams['participant_fee_level']
);
* check with empty array
*/
function testUpdateEmptyParams() {
- $params = array('version' => $this->_apiversion);
+ $params = array();
$participant = $this->callAPIFailure('participant', 'create', $params);
$this->assertEquals($participant['error_message'], 'Mandatory key(s) missing from params array: event_id, contact_id');
}
* check without event_id
*/
function testUpdateWithoutEventId() {
- $participantId = $this->participantCreate(array('contactID' => $this->_individualId, 'eventID' => $this->_eventID, 'version' => $this->_apiversion));
+ $participantId = $this->participantCreate(array('contactID' => $this->_individualId, 'eventID' => $this->_eventID));
$params = array(
'contact_id' => $this->_individualId,
'status_id' => 3,
'role_id' => 3,
'register_date' => '2006-01-21',
'source' => 'US Open',
- 'event_level' => 'Donation',
- 'version' => $this->_apiversion,
- );
+ 'event_level' => 'Donation', );
$participant = $this->callAPIFailure('participant', 'create', $params);
$this->assertEquals($participant['error_message'], 'Mandatory key(s) missing from params array: event_id');
// Cleanup created participant records.
'role_id' => 3,
'register_date' => '2006-01-21',
'source' => 'US Open',
- 'event_level' => 'Donation',
- 'version' => $this->_apiversion,
- );
+ 'event_level' => 'Donation', );
$participant = $this->callAPIFailure('Participant', 'update', $params);
}
'role_id' => 3,
'register_date' => '2006-01-21',
'source' => 'US Open',
- 'event_level' => 'Donation',
- 'version' => $this->_apiversion,
- );
+ 'event_level' => 'Donation', );
$participant = $this->callAPIFailure('participant', 'create', $params);
$result = $this->participantDelete($participantId);
}
- /**
- * check with complete array
- */
- function testUpdate() {
- $participantId = $this->participantCreate(array('contactID' => $this->_individualId, 'eventID' => $this->_eventID, $this->_apiversion));
- $params = array(
- 'id' => $participantId,
- 'contact_id' => $this->_individualId,
- 'event_id' => $this->_eventID,
- 'status_id' => 3,
- 'role_id' => 3,
- 'register_date' => '2006-01-21',
- 'source' => 'US Open',
- 'event_level' => 'Donation',
- 'version' => $this->_apiversion,
- );
- $participant = civicrm_api('participant', 'create', $params);
- $this->assertNotEquals($participant['is_error'], 1);
-
-
- if (!$participant['is_error']) {
- $params['id'] = CRM_Utils_Array::value('id', $participant);
-
- // Create $match array with DAO Field Names and expected values
- $match = array(
- 'id' => CRM_Utils_Array::value('id', $participant),
- );
- // assertDBState compares expected values in $match to actual values in the DB
- $this->assertDBState('CRM_Event_DAO_Participant', $participant['id'], $match);
- }
- // Cleanup created participant records.
- $result = $this->participantDelete($params['id']);
- }
-
-
-
///////////////// civicrm_participant_delete methods
/**
*/
function testParticipantDelete() {
$params = array(
- 'id' => $this->_participantID,
- 'version' => $this->_apiversion,
- );
- $participant = civicrm_api('participant', 'delete', $params);
+ 'id' => $this->_participantID, );
+ $participant = $this->callAPISuccess('participant', 'delete', $params);
$this->assertAPISuccess($participant);
$this->assertDBState('CRM_Event_DAO_Participant', $this->_participantID, NULL, TRUE);
}
*/
function testParticipantDeleteMissingID() {
$params = array(
- 'event_id' => $this->_eventID,
- 'version' => $this->_apiversion,
- );
+ 'event_id' => $this->_eventID, );
$participant = $this->callAPIFailure('participant', 'delete', $params);
$this->assertNotNull($participant['error_message']);
}
function testNestedDelete() {
$description = "Criteria delete by nesting a GET & a DELETE";
$subfile = "NestedDelete";
- $participants = civicrm_api('Participant', 'Get', array('version' => 3));
+ $participants = $this->callAPISuccess('Participant', 'Get', array());
$this->assertEquals($participants['count'], 3);
- $params = array('version' => 3, 'contact_id' => $this->_contactID2, 'api.participant.delete' => 1);
- $participants = civicrm_api('Participant', 'Get', $params);
- $this->documentMe($params, $participants, __FUNCTION__, __FILE__, $description, $subfile, 'Get');
- $participants = civicrm_api('Participant', 'Get', array('version' => 3));
+ $params = array('contact_id' => $this->_contactID2, 'api.participant.delete' => 1);
+ $participants = $this->callAPIAndDocument('Participant', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile, 'Get');
$this->assertEquals(1, $participants['count'], "only one participant should be left. line " . __LINE__);
}
/*
* Test creation of a participant with an associated contribution
*/
function testCreateParticipantWithPayment() {
- $this->_financialTypeId = 1;
+ $this->_contributionTypeId = $this->contributionTypeCreate();
$description = "single function to create contact w partipation & contribution. Note that in the
case of 'contribution' the 'create' is implied (api.contribution.create)";
$subfile = "CreateParticipantPayment";
$params = array(
'contact_type' => 'Individual',
- 'display_name' => 'dlobo',
- 'version' => $this->_apiversion,
- 'api.participant' => array(
+ 'display_name' => 'dlobo', 'api.participant' => array(
'event_id' => $this->_eventID,
'status_id' => 1,
'role_id' => 1,
),
);
- $result = civicrm_api('contact', 'create', $params);
- $this->documentMe($params, $result, __FUNCTION__, __FILE__, $description, $subfile);
+ $result = $this->callAPIAndDocument('contact', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
$this->assertEquals(1, $result['values'][$result['id']]['api.participant_payment.create']['count']);
- civicrm_api('contact', 'delete', array('id' => $result['id'], 'version' => $this->_apiversion));
+ $this->callAPISuccess('contact', 'delete', array('id' => $result['id']));
}
-
- function testParticipantFormattedwithDuplicateParams() {
- $participantContact = $this->individualCreate(NULL);
- $params = array(
- 'contact_id' => $participantContact,
- 'event_id' => $this->_eventID,
- 'version' => 3,
- );
- require_once 'CRM/Event/Import/Parser.php';
- $onDuplicate = CRM_Import_Parser::DUPLICATE_NOCHECK;
- $participant = _civicrm_api3_deprecated_create_participant_formatted($params, $onDuplicate);
- $this->assertEquals($participant['is_error'], 0);
- }
-
- /**
- * Test civicrm_participant_formatted with wrong $onDuplicate
- */
- function testParticipantFormattedwithWrongDuplicateConstant() {
- $participantContact = $this->individualCreate(NULL);
- $params = array(
- 'contact_id' => $participantContact,
- 'event_id' => $this->_eventID,
- 'version' => 3,
- );
- $onDuplicate = 11;
- $participant = _civicrm_api3_deprecated_create_participant_formatted($params, $onDuplicate);
- $this->assertEquals($participant['is_error'], 0);
- }
-
- function testParticipantcheckWithParams() {
- $participantContact = $this->individualCreate(NULL);
- $params = array(
- 'contact_id' => $participantContact,
- 'event_id' => $this->_eventID,
- );
- require_once 'CRM/Event/Import/Parser.php';
- $participant = _civicrm_api3_deprecated_participant_check_params($params);
- $this->assertEquals($participant, TRUE, 'Check the returned True');
- }
-
- /**
- * check get with role id - create 2 registrations with different roles.
- * Test that get without role var returns 2 & with returns one
- TEST COMMENteD OUT AS HAVE GIVIEN UP ON using filters on get
- function testGetParamsRole()
- {
- require_once 'CRM/Event/PseudoConstant.php';
- CRM_Event_PseudoConstant::flush('participantRole');
- $participantRole2 = civicrm_api('Participant', 'Create', array('version' => 3, 'id' => $this->_participantID2, 'participant_role_id' => 2));
-
- $params = array(
-
- 'version' => $this->_apiversion,
-
- );
- $result = civicrm_api('participant','get', $params);
- $this->assertAPISuccess($result);
- $this->assertEquals($result['count'], 3);
-
- $params['participant_role_id'] =2;
- $result = civicrm_api('participant','get', $params);
-
- $this->assertAPISuccess($result, "in line " . __LINE__);
- $this->assertEquals(2,$result['count'], "in line " . __LINE__);
- $this->documentMe($params,$result ,__FUNCTION__,__FILE__);
- }
- */
}