<?php
-
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.3 |
require_once 'CiviTest/CiviUnitTestCase.php';
class api_v3_OptionGroupTest extends CiviUnitTestCase {
- protected $_apiversion;
+ protected $_apiversion = 3;
public $_eNoticeCompliant = TRUE;
protected $_entity = 'OptionGroup';
function setUp() {
- $this->_apiversion = 3;
parent::setUp();
-
$this->_params = array(
'name' => 'our test Option Group',
'is_reserved' => 1,
$this->assertFalse(empty($result['values']), 'In line ' . __LINE__);
}
public function testGetOptionGroupGetFieldsCreateAction() {
- $result = $this->callAPISuccess('option_group', 'getfields', array('action' => 'create', 'version' => 3));
+ $result = $this->callAPISuccess('option_group', 'getfields', array('action' => 'create'));
$this->assertFalse(empty($result['values']), 'In line ' . __LINE__);
$this->assertEquals($result['values']['name']['api.unique'], 1);
}
public function testGetOptionGroupByID() {
- $result = $this->callAPISuccess('option_group', 'get', array('id' => 1, 'version' => 3));
+ $result = $this->callAPISuccess('option_group', 'get', array('id' => 1));
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->assertEquals(1, $result['id'], 'In line ' . __LINE__);
}
public function testGetOptionGroupByName() {
- $params = array('name' => 'preferred_communication_method', 'version' => 3);
+ $params = array('name' => 'preferred_communication_method');
$result = $this->callAPIAndDocument('option_group', 'get', $params, __FUNCTION__, __FILE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->assertEquals(1, $result['id'], 'In line ' . __LINE__);
}
public function testGetOptionGroup() {
- $result = $this->callAPISuccess('option_group', 'get', array('version' => 3));
+ $result = $this->callAPISuccess('option_group', 'get', array());
$this->assertGreaterThan(1, $result['count'], 'In line ' . __LINE__);
}
public function testGetOptionDoesNotExist() {
- $result = $this->callAPISuccess('option_group', 'get', array('name' => 'FSIGUBSFGOMUUBSFGMOOUUBSFGMOOBUFSGMOOIIB', 'version' => 3));
+ $result = $this->callAPISuccess('option_group', 'get', array('name' => 'FSIGUBSFGOMUUBSFGMOOUUBSFGMOOBUFSGMOOIIB'));
$this->assertEquals(0, $result['count'], 'In line ' . __LINE__);
}
public function testGetOptionCreateSuccess() {
- $params = array('version' => $this->_apiversion, 'sequential' => 1, 'name' => 'civicrm_event.amount.560', 'is_reserved' => 1, 'is_active' => 1, 'api.OptionValue.create' => array('label' => 'workshop', 'value' => 35, 'is_default' => 1, 'is_active' => 1, 'format.only_id' => 1));
+ $params = array('sequential' => 1, 'name' => 'civicrm_event.amount.560', 'is_reserved' => 1, 'is_active' => 1, 'api.OptionValue.create' => array('label' => 'workshop', 'value' => 35, 'is_default' => 1, 'is_active' => 1, 'format.only_id' => 1));
$result = $this->callAPIAndDocument('OptionGroup', 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals('civicrm_event.amount.560', $result['values'][0]['name'], 'In line ' . __LINE__);
$this->assertTrue(is_integer($result['values'][0]['api.OptionValue.create']));
$this->assertGreaterThan(0, $result['values'][0]['api.OptionValue.create']);
- $this->callAPISuccess('OptionGroup', 'delete', array('version' => 3, 'id' => $result['id']));
+ $this->callAPISuccess('OptionGroup', 'delete', array('id' => $result['id']));
}
/*
* Test the error message when a failure is due to a key duplication issue
*/
public function testGetOptionCreateFailOnDuplicate() {
- $params = array(
- 'version' => $this->_apiversion,
- 'sequential' => 1,
+ $params = array( 'sequential' => 1,
'name' => 'civicrm_dup entry',
'is_reserved' => 1,
'is_active' => 1,
*/
public function testGetOptionCreateFailRollback() {
- $countFirst = civicrm_api('OptionGroup', 'getcount', array(
- 'version' => 3,
- 'options' => array('limit' => 5000),
+ $countFirst = $this->callAPISuccess('OptionGroup', 'getcount', array(
+ 'options' => array('limit' => 5000),
)
);
- $params = array(
- 'version' => $this->_apiversion,
- 'sequential' => 1,
+ $params = array( 'sequential' => 1,
'name' => 'civicrm_rolback_test',
'is_reserved' => 1,
'is_active' => 1,
),
);
$result = $this->callAPIFailure('OptionGroup', 'create', $params);
- $countAfter = civicrm_api('OptionGroup', 'getcount', array(
- 'version' => 3,
- 'options' => array('limit' => 5000),
+ $countAfter = $this->callAPISuccess('OptionGroup', 'getcount', array(
+ 'options' => array('limit' => 5000),
)
);
$this->assertEquals($countFirst, $countAfter,
function setUp() {
$this->_apiversion = 3;
$this->params = array(
- 'version' => 3,
'name' => 'test status',
'label' => 'I am a test',
'class' => 'Positive',
function tearDown() {}
public function testCreateParticipantStatusType() {
- $result = civicrm_api('participant_status_type', 'create', $this->params);
- $this->documentMe($this->params, $result, __FUNCTION__, __FILE__);
- $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__);
+ $result = $this->callAPIAndDocument('participant_status_type', 'create', $this->params, __FUNCTION__, __FILE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
}
public function testGetParticipantStatusType() {
- $result = civicrm_api('participant_status_type', 'get', $this->params);
- $this->documentMe($this->params, $result, __FUNCTION__, __FILE__);
- $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__);
+ $result = $this->callAPIAndDocument('participant_status_type', 'get', $this->params, __FUNCTION__, __FILE__);
$this->assertEquals(1, $result['count'], 'In line ' . __LINE__);
$this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__);
$this->id = $result['id'];
public function testDeleteParticipantStatusType() {
- $ParticipantStatusType = civicrm_api('ParticipantStatusType', 'Create', $this->params);
- $entity = civicrm_api('participant_status_type', 'get', array('version' => 3));
- $result = civicrm_api('participant_status_type', 'delete', array('version' => 3, 'id' => $ParticipantStatusType['id']));
- $this->documentMe($this->params, $result, __FUNCTION__, __FILE__);
- $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__);
- $getCheck = civicrm_api('ParticipantStatusType', 'GET', array('version' => 3, 'id' => $ParticipantStatusType['id']));
- $checkDeleted = civicrm_api('ParticipantStatusType', 'Get', array(
- 'version' => 3,
- ));
+ $ParticipantStatusType = $this->callAPISuccess('ParticipantStatusType', 'Create', $this->params);
+ $entity = $this->callAPISuccess('participant_status_type', 'get', array());
+ $result = $this->callAPIAndDocument('participant_status_type', 'delete', array('id' => $ParticipantStatusType['id']), __FUNCTION__, __FILE__);
+ $getCheck = $this->callAPISuccess('ParticipantStatusType', 'GET', array('id' => $ParticipantStatusType['id']));
+ $checkDeleted = $this->callAPISuccess('ParticipantStatusType', 'Get', array(
+ ));
$this->assertEquals($entity['count'] - 1, $checkDeleted['count'], 'In line ' . __LINE__);
}
}