$this->assertEquals($result['values'][0]['id'], $this->_eventIds[0]);
}
- public function testGetEventByWrongTitle() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testGetEventByWrongTitle($version) {
+ $this->_apiversion = $version;
$params = array(
'title' => 'No event with that title',
);
$this->assertEquals(0, $result['count']);
}
+ /**
+ * Skip api4 - this api uses deprecated query syntax
+ */
public function testGetEventByIdSort() {
$params = array(
'return.sort' => 'id ASC',
$this->assertEquals(1, $result['id'], ' in line ' . __LINE__);
}
+
/*
* Getting the id back of an event.
* Does not work yet, bug in API
}
*/
-
/**
* Test 'is.Current' option. Existing event is 'old' so only current should be returned
+ * FIXME: Api4
*/
public function testGetIsCurrent() {
$params = array(
/**
* There has been a schema change & the api needs to buffer developers from it
+ * FIXME: Api4
*/
public function testGetPaymentProcessorId() {
$params = $this->_params[0];
$this->assertEquals($result['values'][0]['payment_processor_id'], 1, "handing get payment processor compatibility");
}
- public function testInvalidData() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testInvalidData($version) {
+ $this->_apiversion = $version;
$params = $this->_params[0];
$params['sequential'] = 1;
$params['loc_block_id'] = 100;
}
/**
- * Test 'is.Current' option. Existing event is 'old' so only current should be returned
+ * Test 'is_full' option.
+ * FIXME: Api4
*/
public function testGetSingleReturnIsFull() {
$contactID = $this->individualCreate();
$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 = $this->callAPISuccess('Participant', 'create', array(
- 'participant_status' => 1,
- 'role_id' => 1,
- 'contact_id' => $contactID,
- 'event_id' => $this->_eventIds[0],
- ));
+ 'participant_status' => 1,
+ 'role_id' => 1,
+ 'contact_id' => $contactID,
+ 'event_id' => $this->_eventIds[0],
+ ));
$currentEvent = $this->callAPIAndDocument('Event', 'getsingle', $getEventParams, __FUNCTION__, __FILE__, $description, $subfile);
$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__);
/**
* Chaining get event and loc block.
+ * @param int $version
+ * @dataProvider versionThreeAndFour
*/
- public function testChainingGetLocBlock() {
+ public function testChainingGetLocBlock($version) {
+ $this->_apiversion = $version;
// create a loc block and an event for that loc block.
$eventParams = $this->_params[0];
$eventParams['loc_bloc_id'] = '$value.id';
'id' => $result['id'],
// this chaining request should not break things:
'api.LocBlock.get' => array('id' => '$value.loc_block_id'),
- ));
+ ));
$this->assertEquals($result['id'], $check['id']);
$this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id']));
* Note that the test is written on purpose without any
* variables specific to participant so it can be replicated into other entities
* and / or moved to the automated test suite.
+ * @param int $version
+ * @dataProvider versionThreeAndFour
*/
- public function testCreateWithCustom() {
+ public function testCreateWithCustom($version) {
+ $this->_apiversion = $version;
$ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
$params = $this->_params[0];
$result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
$check = $this->callAPISuccess($this->_entity, 'get', array(
- 'return.custom_' . $ids['custom_field_id'] => 1,
- 'id' => $result['id'],
- ));
+ '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']);
* Check searching on custom fields.
*
* https://issues.civicrm.org/jira/browse/CRM-16036
+ * @param int $version
+ * @dataProvider versionThreeAndFour
*/
- public function testSearchCustomField() {
+ public function testSearchCustomField($version) {
+ $this->_apiversion = $version;
// create custom group with custom field on event
$ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
// Search for events having CRM-16036 as the value for this custom
// field. This should not return anything.
$check = $this->callAPISuccess($this->_entity, 'get', array(
- 'custom_' . $ids['custom_field_id'] => 'CRM-16036',
- ));
+ 'custom_' . $ids['custom_field_id'] => 'CRM-16036',
+ ));
$this->assertEquals(0, $check['count']);
* Check searching on custom fields with IS NULL.
*
* https://issues.civicrm.org/jira/browse/CRM-20740
+ * @param int $version
+ * @dataProvider versionThreeAndFour
*/
- public function testSearchCustomFieldIsNull() {
+ public function testSearchCustomFieldIsNull($version) {
+ $this->_apiversion = $version;
// create custom group with custom field on event
$ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
// Search for events having NULL as the value for this custom
// field. This should return all events created in setUp.
$check = $this->callAPISuccess($this->_entity, 'get', array(
- 'custom_' . $ids['custom_field_id'] => array('IS NULL' => 1),
- ));
+ 'custom_' . $ids['custom_field_id'] => array('IS NULL' => 1),
+ ));
$this->assertGreaterThan(0, $check['count']);
* Test searching on custom fields returning a contact reference.
*
* https://issues.civicrm.org/jira/browse/CRM-16036
+ * FIXME: Api4
*/
public function testEventGetCustomContactRefFieldCRM16036() {
// Create some contact.
* Test searching on custom fields with less than or equal.
*
* See CRM-17101.
+ * @param int $version
+ * @dataProvider versionThreeAndFour
*/
- public function testEventGetCustomFieldLte() {
+ public function testEventGetCustomFieldLte($version) {
+ $this->_apiversion = $version;
// create custom group with custom field on event
$ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
));
}
-
/**
* Test that an event with a price set can be created.
+ * FIXME: Api4
*/
public function testCreatePaidEvent() {
//@todo alter API so that an integer is converted to an array
$this->assertArrayKeyExists('price_set_id', $event);
}
- public function testCreateEventParamsNotArray() {
- $params = NULL;
- $result = $this->callAPIFailure('event', 'create', $params);
- }
-
- public function testCreateEventEmptyParams() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testCreateEventEmptyParams($version) {
+ $this->_apiversion = $version;
$params = array();
$result = $this->callAPIFailure('event', 'create', $params);
}
- public function testCreateEventParamsWithoutTitle() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testCreateEventParamsWithoutTitle($version) {
+ $this->_apiversion = $version;
unset($this->_params['title']);
$result = $this->callAPIFailure('event', 'create', $this->_params);
$this->assertAPIFailure($result);
}
- public function testCreateEventParamsWithoutEventTypeId() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testCreateEventParamsWithoutEventTypeId($version) {
+ $this->_apiversion = $version;
unset($this->_params['event_type_id']);
$result = $this->callAPIFailure('event', 'create', $this->_params);
}
- public function testCreateEventParamsWithoutStartDate() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testCreateEventParamsWithoutStartDate($version) {
+ $this->_apiversion = $version;
unset($this->_params['start_date']);
- $result = $this->callAPIFailure('event', 'create', $this->_params);
+ $result = $this->callAPIFailure('event', 'create', $this->_params, 'start_date');
}
- public function testCreateEventSuccess() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testCreateEventSuccess($version) {
+ $this->_apiversion = $version;
$result = $this->callAPIAndDocument('Event', 'Create', $this->_params[0], __FUNCTION__, __FILE__);
$this->assertArrayHasKey('id', $result['values'][$result['id']]);
$result = $this->callAPISuccess($this->_entity, 'Get', array('id' => $result['id']));
/**
* Test that passing in Unique field names works.
+ * Skip api4 which doesn't use unique names
*/
public function testCreateEventSuccessUniqueFieldNames() {
$this->_params[0]['event_start_date'] = $this->_params[0]['start_date'];
$this->assertEquals($this->_params[0]['event_title'], $result['values'][$result['id']]['title'], 'end date is not set in line ' . __LINE__);
}
- public function testUpdateEvent() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testUpdateEvent($version) {
+ $this->_apiversion = $version;
$result = $this->callAPISuccess('event', 'create', $this->_params[1]);
$params = array(
$this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id']));
}
-
- public function testDeleteEmptyParams() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testDeleteEmptyParams($version) {
+ $this->_apiversion = $version;
$result = $this->callAPIFailure('Event', 'Delete', array());
}
- public function testDelete() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testDelete($version) {
+ $this->_apiversion = $version;
$params = array(
'id' => $this->_eventIds[0],
);
/**
* Check event_id still supported for delete.
+ * @param int $version
+ * @dataProvider versionThreeAndFour
*/
- public function testDeleteWithEventId() {
+ public function testDeleteWithEventId($version) {
+ $this->_apiversion = $version;
$params = array(
'event_id' => $this->_eventIds[0],
);
/**
* Trying to delete an event with participants should return error.
+ * @param int $version
+ * @dataProvider versionThreeAndFour
*/
- public function testDeleteWithExistingParticipant() {
+ public function testDeleteWithExistingParticipant($version) {
+ $this->_apiversion = $version;
$contactID = $this->individualCreate();
$this->participantCreate(
array(
$this->callAPISuccess('Event', 'Delete', array('id' => $this->_eventIds[0]));
}
- public function testDeleteWithWrongEventId() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testDeleteWithWrongEventId($version) {
+ $this->_apiversion = $version;
$params = array('event_id' => $this->_eventIds[0]);
$result = $this->callAPISuccess('Event', 'Delete', $params);
// try to delete again - there's no such event anymore
/**
* Test civicrm_event_search with wrong params type.
+ * @param int $version
+ * @dataProvider versionThreeAndFour
*/
- public function testSearchWrongParamsType() {
+ public function testSearchWrongParamsType($version) {
+ $this->_apiversion = $version;
$params = 'a string';
$result = $this->callAPIFailure('event', 'get', $params);
}
/**
* Test civicrm_event_search with empty params.
+ * @param int $version
+ * @dataProvider versionThreeAndFour
*/
- public function testSearchEmptyParams() {
+ public function testSearchEmptyParams($version) {
+ $this->_apiversion = $version;
$this->callAPISuccess('event', 'create', $this->_params[1]);
$getParams = array(
/**
* Test civicrm_event_search. Success expected.
+ * @param int $version
+ * @dataProvider versionThreeAndFour
*/
- public function testSearch() {
+ public function testSearch($version) {
+ $this->_apiversion = $version;
$params = array(
'event_type_id' => 1,
'return.title' => 1,
$this->assertEquals(2, $result['count'], ' 2 results returned In line ' . __LINE__);
}
- public function testEventCreationPermissions() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testEventCreationPermissions($version) {
+ $this->_apiversion = $version;
$params = array(
'event_type_id' => 1,
'start_date' => '2010-10-03',
);
$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; 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');
+ $result = $this->callAPIFailure('event', 'create', $params, 'failed');
$config->userPermissionClass->permissions = array(
'access CiviEvent',
$result = $this->callAPISuccess('event', 'create', $params);
}
- public function testgetfields() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testgetfields($version) {
+ $this->_apiversion = $version;
$description = "Demonstrate use of getfields to interrogate api.";
$params = array('action' => 'create');
$result = $this->callAPISuccess('event', 'getfields', $params);
- $this->assertEquals(1, $result['values']['is_active']['api.default']);
+ $this->assertEquals('is_active', $result['values']['is_active']['name']);
}
/**
$this->assertEquals(1, $result['values']['is_active']['api.default']);
}
+ /**
+ * Skip api4 - output is different
+ */
public function testgetfieldsGet() {
$description = "Demonstrate use of getfields to interrogate api.";
$params = array('action' => 'get');
$this->assertEquals('title', $result['values']['event_title']['name']);
}
+ /**
+ * Skip api4 - output is different
+ */
public function testgetfieldsDelete() {
$description = "Demonstrate use of getfields to interrogate api.";
$params = array('action' => 'delete');
$this->assertEquals(1, $result['values']['id']['api.required']);
}
- public function testCreateFromTemplate() {
+ /**
+ * @param int $version
+ * @dataProvider versionThreeAndFour
+ */
+ public function testCreateFromTemplate($version) {
+ $this->_apiversion = $version;
$templateParams = array(
'summary' => 'Sign up now to learn the results of this unit test',
'description' => 'This event is created from a template, so all the values should be the same as the original ones.',