From afd404ea099535fecc288c92137b2ad244831bfa Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 26 Jul 2013 16:32:30 +1200 Subject: [PATCH] CRM-13072 upgrade getAndCheck function & participantTest class --- tests/phpunit/CiviTest/CiviUnitTestCase.php | 25 +- tests/phpunit/api/v3/ParticipantTest.php | 323 +++++--------------- 2 files changed, 99 insertions(+), 249 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 0b1ace490d..0ac04ce3a3 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -2065,9 +2065,20 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) else { $keys[CRM_Utils_Array::Value('name', $settings, $field)] = CRM_Utils_Array::value('name', $settings, $field); } - - if (CRM_Utils_Array::value('type', $settings) == CRM_Utils_Type::T_DATE) { - $dateFields[] = $field; + $type = CRM_Utils_Array::value('type', $settings); + if ($type == CRM_Utils_Type::T_DATE) { + $dateFields[] = $settings['name']; + // we should identify both real names & unique names as dates + if($field != $settings['name']) { + $dateFields[] = $field; + } + } + if($type == CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME) { + $dateTimeFields[] = $settings['name']; + // we should identify both real names & unique names as dates + if($field != $settings['name']) { + $dateTimeFields[] = $field; + } } } @@ -2080,14 +2091,18 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) } foreach ($params as $key => $value) { - if ($key == 'version' || substr($key, 0, 3) == 'api') { + if ($key == 'version' || substr($key, 0, 3) == 'api' || !array_key_exists($keys[$key], $result)) { continue; } if (in_array($key, $dateFields)) { $value = date('Y-m-d', strtotime($value)); $result[$key] = date('Y-m-d', strtotime($result[$key])); } - $this->assertEquals($value, $result[$keys[$key]], $key . " GetandCheck function determines that value: $value doesn't match " . print_r($result, TRUE) . $errorText); + if (in_array($key, $dateTimeFields)) { + $value = date('Y-m-d H:i:s', strtotime($value)); + $result[$keys[$key]] = date('Y-m-d H:i:s', strtotime(CRM_Utils_Array::value($keys[$key], $result, CRM_Utils_Array::value($uniquekey, $result)))); + } + $this->assertEquals($value, $result[$keys[$key]], $key . " GetandCheck function determines that for key {$key} value: $value doesn't match " . print_r($result[$keys[$key]], TRUE) . $errorText); } } diff --git a/tests/phpunit/api/v3/ParticipantTest.php b/tests/phpunit/api/v3/ParticipantTest.php index f1a617bb04..1b4ea3ac82 100644 --- a/tests/phpunit/api/v3/ParticipantTest.php +++ b/tests/phpunit/api/v3/ParticipantTest.php @@ -69,8 +69,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { $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, @@ -79,7 +79,6 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { // to ensure it matches later on 'register_date' => '2007-07-21 00:00:00', 'source' => 'Online Event Registration: API Testing', - 'version' => $this->_apiversion, ); } @@ -104,12 +103,11 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { $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']); @@ -140,7 +138,6 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { function testGetParticipantIdOnly() { $params = array( 'participant_id' => $this->_participantID, - 'version' => $this->_apiversion, 'return' => array( 'participant_id', 'event_id', @@ -148,18 +145,17 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { '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'); @@ -171,11 +167,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { 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'); @@ -188,19 +181,16 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { 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'); @@ -211,13 +201,11 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { */ 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']]); } @@ -226,10 +214,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { */ 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__ @@ -255,11 +241,9 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { 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']); } @@ -270,31 +254,19 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { 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); } @@ -305,9 +277,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { 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'); @@ -320,9 +291,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { // 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); } @@ -336,9 +306,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { '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."); } @@ -356,23 +325,14 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { $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 */ @@ -387,14 +347,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { 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); } /** @@ -404,14 +358,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { 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); } /** @@ -421,17 +369,9 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { $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'); } /** @@ -440,26 +380,21 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { 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'); } /* @@ -467,36 +402,54 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { */ 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'] ); @@ -517,7 +470,7 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { * 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'); } @@ -526,16 +479,14 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { * 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. @@ -552,9 +503,7 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { '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); } @@ -573,49 +522,11 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { '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 /** @@ -639,10 +550,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { */ 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); } @@ -654,9 +563,7 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { */ 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']); } @@ -666,27 +573,23 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { 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, @@ -703,77 +606,9 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { ), ); - $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__); - } - */ } -- 2.25.1