Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
justinfreeman (Agileware)
Core
Commits
f70a6752
Commit
f70a6752
authored
11 years ago
by
eileen
Browse files
Options
Downloads
Patches
Plain Diff
remove obsolete code from api - add test to check no regression
parent
8cba5814
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/v3/Contribution.php
+0
-27
0 additions, 27 deletions
api/v3/Contribution.php
tests/phpunit/api/v3/ContributionTest.php
+14
-4
14 additions, 4 deletions
tests/phpunit/api/v3/ContributionTest.php
with
14 additions
and
31 deletions
api/v3/Contribution.php
+
0
−
27
View file @
f70a6752
...
...
@@ -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
();
}
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/api/v3/ContributionTest.php
+
14
−
4
View file @
f70a6752
...
...
@@ -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
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment