Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
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
Development
CiviCRM Core
Commits
f2c927f5
Commit
f2c927f5
authored
4 years ago
by
eileen
Browse files
Options
Downloads
Patches
Plain Diff
financial#148
fully deprecate loadObjects function
parent
927b3ade
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Core/Payment/BaseIPN.php
+3
-0
3 additions, 0 deletions
CRM/Core/Payment/BaseIPN.php
CRM/Core/Payment/PayPalProIPN.php
+9
-6
9 additions, 6 deletions
CRM/Core/Payment/PayPalProIPN.php
tests/phpunit/CRM/Core/Payment/BaseIPNTest.php
+1
-115
1 addition, 115 deletions
tests/phpunit/CRM/Core/Payment/BaseIPNTest.php
with
13 additions
and
121 deletions
CRM/Core/Payment/BaseIPN.php
+
3
−
0
View file @
f2c927f5
...
...
@@ -140,6 +140,8 @@ class CRM_Core_Payment_BaseIPN {
/**
* Load objects related to contribution.
*
* @deprecated
*
* @input array information from Payment processor
*
* @param array $input
...
...
@@ -152,6 +154,7 @@ class CRM_Core_Payment_BaseIPN {
* @throws \CRM_Core_Exception
*/
public
function
loadObjects
(
$input
,
&
$ids
,
&
$objects
,
$required
,
$paymentProcessorID
)
{
CRM_Core_Error
::
deprecatedFunctionWarning
(
'use api methods in ipn'
);
$contribution
=
&
$objects
[
'contribution'
];
$ids
[
'paymentProcessor'
]
=
$paymentProcessorID
;
$success
=
$contribution
->
loadRelatedObjects
(
$input
,
$ids
);
...
...
This diff is collapsed.
Click to expand it.
CRM/Core/Payment/PayPalProIPN.php
+
9
−
6
View file @
f2c927f5
...
...
@@ -482,9 +482,10 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr
unset
(
$ids
[
'contributionPage'
]);
}
if
(
!
$this
->
loadObjects
(
$input
,
$ids
,
$objects
,
TRUE
,
$paymentProcessorID
))
{
return
;
}
$contribution
=
&
$objects
[
'contribution'
];
$ids
[
'paymentProcessor'
]
=
$paymentProcessorID
;
$contribution
->
loadRelatedObjects
(
$input
,
$ids
);
$objects
=
array_merge
(
$objects
,
$contribution
->
_relatedObjects
);
$input
[
'payment_processor_id'
]
=
$paymentProcessorID
;
...
...
@@ -640,9 +641,11 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr
unset
(
$ids
[
'contributionPage'
]);
}
if
(
!
$this
->
loadObjects
(
$input
,
$ids
,
$objects
,
TRUE
,
$paymentProcessorID
))
{
throw
new
CRM_Core_Exception
(
'Data did not validate'
);
}
$contribution
=
&
$objects
[
'contribution'
];
$ids
[
'paymentProcessor'
]
=
$paymentProcessorID
;
$contribution
->
loadRelatedObjects
(
$input
,
$ids
);
$objects
=
array_merge
(
$objects
,
$contribution
->
_relatedObjects
);
$this
->
recur
(
$input
,
$ids
,
$objects
[
'contributionRecur'
],
$objects
[
'contribution'
],
$isFirst
);
}
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CRM/Core/Payment/BaseIPNTest.php
+
1
−
115
View file @
f2c927f5
...
...
@@ -98,43 +98,6 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase {
CRM_Member_PseudoConstant
::
membershipStatus
(
NULL
,
NULL
,
'name'
,
TRUE
);
}
/**
* Test the LoadObjects function with recurring membership data.
*/
public
function
testLoadMembershipObjects
()
{
$this
->
_setUpMembershipObjects
();
$this
->
_setUpRecurringContribution
();
$this
->
IPN
->
loadObjects
(
$this
->
input
,
$this
->
ids
,
$this
->
objects
,
FALSE
,
$this
->
_processorId
);
$this
->
assertNotEmpty
(
$this
->
objects
[
'membership'
]);
$this
->
assertArrayHasKey
(
$this
->
_membershipId
.
'_'
.
$this
->
_membershipTypeID
,
$this
->
objects
[
'membership'
]);
$this
->
assertTrue
(
is_a
(
$this
->
objects
[
'membership'
][
$this
->
_membershipId
.
'_'
.
$this
->
_membershipTypeID
],
'CRM_Member_BAO_Membership'
));
$this
->
assertTrue
(
is_a
(
$this
->
objects
[
'financialType'
],
'CRM_Financial_BAO_FinancialType'
));
$this
->
assertNotEmpty
(
$this
->
objects
[
'contributionRecur'
]);
$this
->
assertNotEmpty
(
$this
->
objects
[
'paymentProcessor'
]);
}
/**
* Test the LoadObjects function with recurring membership data.
*/
public
function
testLoadMembershipObjectsNoLeakage
()
{
$this
->
_setUpMembershipObjects
();
$this
->
_setUpRecurringContribution
();
$this
->
IPN
->
loadObjects
(
$this
->
input
,
$this
->
ids
,
$this
->
objects
,
FALSE
,
$this
->
_processorId
);
$this
->
assertEquals
(
'Anthony'
,
$this
->
objects
[
'contact'
]
->
first_name
);
$this
->
ids
[
'contact'
]
=
$this
->
_contactId
=
$this
->
individualCreate
([
'first_name'
=>
'Donald'
,
'last_name'
=>
'Duck'
,
'email'
=>
'the-don@duckville.com'
,
]);
$contribution
=
$this
->
callAPISuccess
(
'contribution'
,
'create'
,
array_merge
(
$this
->
_contributionParams
,
[
'invoice_id'
=>
'abc'
]));
$this
->
_contributionId
=
$contribution
[
'id'
];
$this
->
_setUpMembershipObjects
();
$this
->
input
[
'invoiceID'
]
=
'abc'
;
$this
->
IPN
->
loadObjects
(
$this
->
input
,
$this
->
ids
,
$this
->
objects
,
FALSE
,
$this
->
_processorId
);
$this
->
assertEquals
(
'Donald'
,
$this
->
objects
[
'contact'
]
->
first_name
);
}
/**
* Test the LoadObjects function with recurring membership data.
*/
...
...
@@ -189,8 +152,6 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase {
$this
->
_membershipTypeID
=
$this
->
membershipTypeCreate
([
'name'
=>
'Fowl'
]);
$this
->
_setUpMembershipObjects
();
$this
->
input
[
'invoiceID'
]
=
'abc'
;
$this
->
IPN
->
loadObjects
(
$this
->
input
,
$this
->
ids
,
$this
->
objects
,
FALSE
,
$this
->
_processorId
);
$this
->
assertEquals
(
'Donald'
,
$this
->
objects
[
'contact'
]
->
first_name
);
$contribution
=
new
CRM_Contribute_BAO_Contribution
();
$contribution
->
id
=
$this
->
_contributionId
;
$msg
=
$contribution
->
composeMessageArray
(
$this
->
input
,
$this
->
ids
,
$values
);
...
...
@@ -211,31 +172,14 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase {
$this
->
assertContains
(
'Membership Type: General'
,
$msg
[
'body'
]);
}
/**
* Test that loadObjects works with participant values.
*/
public
function
testLoadParticipantObjects
()
{
$this
->
_setUpParticipantObjects
();
$this
->
IPN
->
loadObjects
(
$this
->
input
,
$this
->
ids
,
$this
->
objects
,
FALSE
,
$this
->
_processorId
);
$this
->
assertNotEmpty
(
$this
->
objects
[
'participant'
]);
$this
->
assertTrue
(
is_a
(
$this
->
objects
[
'participant'
],
'CRM_Event_BAO_Participant'
));
$this
->
assertTrue
(
is_a
(
$this
->
objects
[
'financialType'
],
'CRM_Financial_BAO_FinancialType'
));
$this
->
assertNotEmpty
(
$this
->
objects
[
'event'
]);
$this
->
assertTrue
(
is_a
(
$this
->
objects
[
'event'
],
'CRM_Event_BAO_Event'
));
$this
->
assertTrue
(
is_a
(
$this
->
objects
[
'contribution'
],
'CRM_Contribute_BAO_Contribution'
));
$this
->
assertNotEmpty
(
$this
->
objects
[
'event'
]
->
id
);
}
/**
* Test the LoadObjects function with a participant.
*/
public
function
testComposeMailParticipant
()
{
$this
->
_setUpParticipantObjects
();
$this
->
IPN
->
loadObjects
(
$this
->
input
,
$this
->
ids
,
$this
->
objects
,
FALSE
,
$this
->
_processorId
);
$values
=
[];
$this
->
assertNotEmpty
(
$this
->
objects
[
'event'
]);
$contribution
=
new
CRM_Contribute_BAO_Contribution
();
$contribution
->
id
=
$this
->
_contributionId
;
$contribution
->
loadRelatedObjects
(
$this
->
input
,
$this
->
ids
);
$msg
=
$contribution
->
composeMessageArray
(
$this
->
input
,
$this
->
ids
,
$values
);
$this
->
assertContains
(
'registration has been received and your status has been updated to Attended.'
,
$msg
[
'body'
]);
$this
->
assertContains
(
'Annual CiviCRM meet'
,
$msg
[
'html'
]);
...
...
@@ -291,43 +235,6 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase {
$mut
->
stop
();
}
/**
* Test that loadObjects works with participant values.
*/
public
function
testLoadPledgeObjects
()
{
$this
->
_setUpPledgeObjects
();
$this
->
IPN
->
loadObjects
(
$this
->
input
,
$this
->
ids
,
$this
->
objects
,
FALSE
,
$this
->
_processorId
);
$this
->
assertNotEmpty
(
$this
->
objects
[
'pledge_payment'
][
0
]);
$this
->
assertTrue
(
is_a
(
$this
->
objects
[
'financialType'
],
'CRM_Financial_BAO_FinancialType'
));
$this
->
assertTrue
(
is_a
(
$this
->
objects
[
'contribution'
],
'CRM_Contribute_BAO_Contribution'
));
$this
->
assertTrue
(
is_a
(
$this
->
objects
[
'pledge_payment'
][
0
],
'CRM_Pledge_BAO_PledgePayment'
));
$this
->
assertNotEmpty
(
$this
->
objects
[
'pledge_payment'
][
0
]
->
id
);
$this
->
assertEquals
(
$this
->
_financialTypeId
,
$this
->
objects
[
'financialType'
]
->
id
);
$this
->
assertEquals
(
$this
->
_processorId
,
$this
->
objects
[
'paymentProcessor'
][
'id'
]);
$this
->
assertEquals
(
$this
->
_contributionId
,
$this
->
objects
[
'contribution'
]
->
id
);
$this
->
assertEquals
(
$this
->
_contactId
,
$this
->
objects
[
'contact'
]
->
id
);
$this
->
assertEquals
(
$this
->
_pledgeId
,
$this
->
objects
[
'pledge_payment'
][
0
]
->
pledge_id
);
}
/**
* Test that loadObjects works with participant values.
*/
public
function
testLoadPledgeObjectsInvalidPledgeID
()
{
$this
->
_setUpPledgeObjects
();
$this
->
ids
[
'pledge_payment'
][
0
]
=
0
;
$this
->
IPN
->
loadObjects
(
$this
->
input
,
$this
->
ids
,
$this
->
objects
,
TRUE
,
NULL
);
$this
->
assertArrayNotHasKey
(
'pledge_payment'
,
$this
->
objects
);
$this
->
ids
[
'pledge_payment'
][
0
]
=
999
;
try
{
$this
->
IPN
->
loadObjects
(
$this
->
input
,
$this
->
ids
,
$this
->
objects
,
TRUE
,
$this
->
_processorId
);
}
catch
(
CRM_Core_Exception
$e
)
{
$this
->
assertEquals
(
'Could not find pledge payment record: 999'
,
$e
->
getMessage
());
}
}
/**
* Test the LoadObjects function with a pledge.
*/
...
...
@@ -339,27 +246,6 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase {
$this
->
assertContains
(
'Contribution Information'
,
$msg
[
'html'
]);
}
/**
* Test that an error is returned if required set & no contribution page.
*/
public
function
testRequiredWithoutProcessorID
()
{
$this
->
_setUpPledgeObjects
();
// error is only returned if $required set to True
$result
=
$this
->
IPN
->
loadObjects
(
$this
->
input
,
$this
->
ids
,
$this
->
objects
,
FALSE
,
NULL
);
$this
->
assertEquals
(
TRUE
,
$result
);
}
/**
* Test that if part of $input the payment processor loads OK.
*
* It's preferable to pass it in as it cannot be correctly calculated.
*/
public
function
testPaymentProcessorLoadsAsParam
()
{
$this
->
_setUpContributionObjects
();
$this
->
input
=
array_merge
(
$this
->
input
,
[
'payment_processor_id'
=>
$this
->
_processorId
]);
$this
->
assertTrue
(
$this
->
IPN
->
loadObjects
(
$this
->
input
,
$this
->
ids
,
$this
->
objects
,
TRUE
,
NULL
));
}
public
function
testThatCancellingEventPaymentWillCancelAllAdditionalPendingParticipantsAndCreateCancellationActivities
()
{
$this
->
_setUpParticipantObjects
(
'Pending from incomplete transaction'
);
$additionalParticipantId
=
$this
->
participantCreate
([
...
...
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