Skip to content
Snippets Groups Projects
Commit f70a6752 authored by eileen's avatar eileen
Browse files

remove obsolete code from api - add test to check no regression

parent 8cba5814
Branches
Tags
No related merge requests found
......@@ -261,34 +261,7 @@ function _civicrm_api3_contribution_get_spec(&$params) {
*/
function _civicrm_api3_contribute_format_params($params, &$values, $create = FALSE) {
//legacy way of formatting from v2 api - v3 way is to define metadata & do it in the api layer
require_once 'api/v3/utils.php';
_civicrm_api3_filter_fields_for_bao('Contribution', $params, $values);
foreach ($params as $key => $value) {
// ignore empty values or empty arrays etc
if (CRM_Utils_System::isNull($value)) {
continue;
}
// note that this is legacy handling - these should be handled at the api layer
switch ($key) {
case 'financial_type' :// should be dealt with either api pseudoconstant in validate_integer fn
$contributionTypeId = CRM_Utils_Array::key ( ucfirst ( $value ), CRM_Contribute_PseudoConstant::financialType() );
if ($contributionTypeId) {
if (CRM_Utils_Array::value('financial_type_id', $values) && $contributionTypeId != $values['financial_type_id']) {
throw new Exception("Mismatched Financial Type and Financial Type Id");
}
$values ['financial_type_id'] = $contributionTypeId;
}
else {
throw new Exception("Invalid Financial Type");
}
break;
default:
break;
}
}
return array();
}
......
......@@ -506,8 +506,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
$this->_checkFinancialRecords($contribution, 'offline');
$this->contributionGetnCheck($params, $contribution['id']);
}
/*
*
/**
* test create with valid payment instument
*/
function testCreateContributionWithPaymentInstrument() {
$params = $this->_params + array('payment_instrument' => 'EFT');
......@@ -776,7 +776,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
}
/*
/**
* Function tests that additional financial records are created when online contribution is created
*/
function testCreateContributionOnline() {
......@@ -809,7 +809,17 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
$this->_checkFinancialRecords($contribution, 'online');
}
/*
/**
* in the interests of removing financial type / contribution type checks from
* legacy format function lets test that the api is doing this for us
*/
function testCreateInvalidFinancialType() {
$params = $this->_params;
$params['financial_type_id'] = 99999;
$result = $this->callAPIFailure($this->_entity, 'create', $params, "'99999' is not a valid option for field financial_type_id");
}
/**
* Function tests that additional financial records are created when online contribution with pay later option
* is created
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment