require_once 'CiviTest/CiviUnitTestCase.php';
+
+/**
+ * Class api_v3_EventTest
+ */
class api_v3_EventTest extends CiviUnitTestCase {
protected $_params;
protected $_apiversion;
protected $_entity;
+ /**
+ * @return array
+ */
function get_info() {
return array(
'name' => 'Event Create',
*/
- /*
- * Test 'is.Current' option. Existing event is 'old' so only current should be returned
- */
+ /**
+ * Test 'is.Current' option. Existing event is 'old' so only current should be returned
+ */
function testGetIsCurrent() {
$params = array(
'isCurrent' => 1,
$this->assertEquals(3, $allEvents['count'], 'confirm three events exist (ie. two not found) ' . __LINE__);
$this->assertEquals($currentEvent['id'], $result['id'], '');
}
-/*
- * There has been a schema change & the api needs to buffer developers from it
- */
+
+ /**
+ * There has been a schema change & the api needs to buffer developers from it
+ */
function testGetPaymentProcessorId() {
$params = $this->_params[0];
$params['payment_processor_id'] = 1;
}
- /*
- * Test 'is.Current' option. Existing event is 'old' so only current should be returned
- */
+ /**
+ * Test 'is.Current' option. Existing event is 'old' so only current should be returned
+ */
function testGetSingleReturnIsFull() {
$contactID = $this->individualCreate();
$params = array(
///////////////// civicrm_event_create methods
/**
- * check with complete array + custom field
+ * Check with complete array + custom field
* 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
$this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id']));
}
+ /**
+ * Test that an event with a price set can be created
+ */
+ function testCreatePaidEvent() {
+ //@todo alter API so that an integer is converted to an array
+ $priceSetParams = array('price_set_id' => (array) 1, 'is_monetary' => 1);
+ $result = $this->callAPISuccess('Event', 'Create', array_merge($this->_params[0], $priceSetParams));
+ $event = $this->callAPISuccess('Event', 'getsingle', array('id' => $result['id'], 'return' => 'price_set_id'));
+ $this->assertArrayKeyExists('price_set_id', $event);
+ }
+
function testCreateEventParamsNotArray() {
$params = NULL;
$result = $this->callAPIFailure('event', 'create', $params);
$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__);
}
- /*
- * Test that passing in Unique field names works
- */
+
+ /**
+ * Test that passing in Unique field names works
+ */
function testCreateEventSuccessUniqueFieldNames() {
$this->_params[0]['event_start_date'] = $this->_params[0]['start_date'];
unset($this->_params[1]['start_date']);
}
/**
- * check event_id still supported for delete
+ * Check event_id still supported for delete
*/
function testDeleteWithEventId() {
$params = array(
$result = $this->callAPISuccess('Event', 'Delete', $params);
$this->assertAPISuccess($result, 'in line ' . __LINE__);
}
- /*
- * Trying to delete an event with participants should return error
- */
+
+ /**
+ * Trying to delete an event with participants should return error
+ */
function testDeleteWithExistingParticipant() {
$contactID = $this->individualCreate();
$participantID = $this->participantCreate(
}
function testgetfields() {
- $description = "demonstrate use of getfields to interogate api";
+ $description = "demonstrate use of getfields to interrogate api";
$params = array('action' => 'create');
$result = $this->callAPISuccess('event', 'getfields', $params);
$this->assertEquals(1, $result['values']['title']['api.required'], 'in line ' . __LINE__);
}
- /*
- * test api_action param also works
- */
+
+ /**
+ * Test api_action param also works
+ */
function testgetfieldsRest() {
- $description = "demonstrate use of getfields to interogate api";
+ $description = "demonstrate use of getfields to interrogate api";
$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";
+ $description = "demonstrate use of getfields to interrogate api";
$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";
+ $description = "demonstrate use of getfields to interrogate api";
$params = array('action' => 'delete');
$result = $this->callAPISuccess('event', 'getfields', $params);
$this->assertEquals(1, $result['values']['id']['api.required']);