From: eileen Date: Fri, 26 Jul 2013 09:02:22 +0000 (+1200) Subject: CRM-13072 upgrade participant status test X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=0505d9d2a2c575d5aea7840bf7c07e16f2248c29;p=civicrm-core.git CRM-13072 upgrade participant status test --- diff --git a/tests/phpunit/api/v3/OptionGroupTest.php b/tests/phpunit/api/v3/OptionGroupTest.php index 5d95381271..8d2df835ad 100644 --- a/tests/phpunit/api/v3/OptionGroupTest.php +++ b/tests/phpunit/api/v3/OptionGroupTest.php @@ -1,5 +1,4 @@ _apiversion = 3; parent::setUp(); - $this->_params = array( 'name' => 'our test Option Group', 'is_reserved' => 1, @@ -53,49 +50,47 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase { $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, @@ -111,14 +106,11 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase { */ 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, @@ -131,9 +123,8 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase { ), ); $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, diff --git a/tests/phpunit/api/v3/ParticipantStatusTypeTest.php b/tests/phpunit/api/v3/ParticipantStatusTypeTest.php index 46f6a16738..fca74d9574 100644 --- a/tests/phpunit/api/v3/ParticipantStatusTypeTest.php +++ b/tests/phpunit/api/v3/ParticipantStatusTypeTest.php @@ -38,7 +38,6 @@ class api_v3_ParticipantStatusTypeTest extends CiviUnitTestCase { function setUp() { $this->_apiversion = 3; $this->params = array( - 'version' => 3, 'name' => 'test status', 'label' => 'I am a test', 'class' => 'Positive', @@ -54,17 +53,13 @@ class api_v3_ParticipantStatusTypeTest extends CiviUnitTestCase { 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']; @@ -72,15 +67,12 @@ class api_v3_ParticipantStatusTypeTest extends CiviUnitTestCase { 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__); } }