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
4eb35a8c
Unverified
Commit
4eb35a8c
authored
4 years ago
by
Eileen McNaughton
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #18539 from eileenmcnaughton/ppcancel
[NFC] Cleanup in test class
parents
fab434bc
059b1442
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php
+13
-18
13 additions, 18 deletions
tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php
with
13 additions
and
18 deletions
tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php
+
13
−
18
View file @
4eb35a8c
...
...
@@ -22,12 +22,6 @@ class CRM_Core_Payment_PayPalIPNTest extends CiviUnitTestCase {
protected
$_contributionPageID
;
protected
$_paymentProcessorID
;
protected
$_customFieldID
;
/**
* IDs of entities created to support the tests.
*
* @var array
*/
protected
$ids
=
[];
/**
* Set up function.
...
...
@@ -36,8 +30,8 @@ class CRM_Core_Payment_PayPalIPNTest extends CiviUnitTestCase {
parent
::
setUp
();
$this
->
_paymentProcessorID
=
$this
->
paymentProcessorCreate
([
'is_test'
=>
0
,
'payment_processor_type_id'
=>
'PayPal_Standard'
]);
$this
->
_contactID
=
$this
->
individualCreate
();
$contributionPage
=
$this
->
callAPISuccess
(
'
c
ontribution
_p
age'
,
'create'
,
[
'title'
=>
"
Test Contribution Page
"
,
$contributionPage
=
$this
->
callAPISuccess
(
'
C
ontribution
P
age'
,
'create'
,
[
'title'
=>
'
Test Contribution Page
'
,
'financial_type_id'
=>
$this
->
_financialTypeID
,
'currency'
=>
'USD'
,
'payment_processor'
=>
$this
->
_paymentProcessorID
,
...
...
@@ -50,6 +44,7 @@ class CRM_Core_Payment_PayPalIPNTest extends CiviUnitTestCase {
*/
public
function
tearDown
()
{
$this
->
quickCleanUpFinancialEntities
();
parent
::
tearDown
();
}
/**
...
...
@@ -111,11 +106,11 @@ class CRM_Core_Payment_PayPalIPNTest extends CiviUnitTestCase {
$this
->
setupRecurringPaymentProcessorTransaction
([],
[
'total_amount'
=>
'15.00'
]);
$paypalIPN
=
new
CRM_Core_Payment_PayPalIPN
(
$this
->
getPaypalRecurTransaction
());
$paypalIPN
->
main
();
$contribution1
=
$this
->
callAPISuccess
(
'
c
ontribution'
,
'getsingle'
,
[
'id'
=>
$this
->
_contributionID
]);
$contribution1
=
$this
->
callAPISuccess
(
'
C
ontribution'
,
'getsingle'
,
[
'id'
=>
$this
->
_contributionID
]);
$this
->
assertEquals
(
1
,
$contribution1
[
'contribution_status_id'
]);
$this
->
assertEquals
(
'8XA571746W2698126'
,
$contribution1
[
'trxn_id'
]);
// source gets set by processor
$this
->
assertTrue
(
substr
(
$contribution1
[
'contribution_source'
],
0
,
20
)
==
"
Online Contribution:
"
);
$this
->
assertTrue
(
substr
(
$contribution1
[
'contribution_source'
],
0
,
20
)
==
=
'
Online Contribution:
'
);
$contributionRecur
=
$this
->
callAPISuccess
(
'contribution_recur'
,
'getsingle'
,
[
'id'
=>
$this
->
_contributionRecurID
]);
$this
->
assertEquals
(
5
,
$contributionRecur
[
'contribution_status_id'
]);
$paypalIPN
=
new
CRM_Core_Payment_PayPalIPN
(
$this
->
getPaypalRecurSubsequentTransaction
());
...
...
@@ -301,22 +296,22 @@ class CRM_Core_Payment_PayPalIPNTest extends CiviUnitTestCase {
];
$this
->
_contributionID
=
$this
->
contributionCreate
(
$params
);
$this
->
createCustomField
();
$contribution
=
$this
->
callAPISuccess
(
'contribution'
,
'get'
,
[
'id'
=>
$this
->
_contributionID
,
'sequential'
=>
1
]);
$contribution
=
$this
->
callAPISuccess
GetSingle
(
'contribution'
,
[
'id'
=>
$this
->
_contributionID
]);
// assert that contribution created before handling payment via paypal standard has no transaction id set and pending status
$this
->
assertEquals
(
NULL
,
$contribution
[
'
values'
][
0
][
'
trxn_id'
]);
$this
->
assertEquals
(
$pendingStatusID
,
$contribution
[
'
values'
][
0
][
'
contribution_status_id'
]);
$this
->
assertEquals
(
NULL
,
$contribution
[
'trxn_id'
]);
$this
->
assertEquals
(
$pendingStatusID
,
$contribution
[
'contribution_status_id'
]);
$this
->
hookClass
->
setHook
(
'civicrm_postIPNProcess'
,
[
$this
,
'hookCiviCRMAlterIPNData'
]);
global
$_REQUEST
;
$_REQUEST
=
[
'q'
=>
CRM_Utils_System
::
url
(
'civicrm/payment/ipn/'
.
$this
->
_paymentProcessorID
)]
+
$this
->
getPaypalTransaction
();
$mut
=
new
CiviMailUtils
(
$this
,
TRUE
);
$payment
=
CRM_Core_Payment
::
handlePaymentMethod
(
'PaymentNotification'
,
[
'processor_id'
=>
$this
->
_paymentProcessorID
]);
CRM_Core_Payment
::
handlePaymentMethod
(
'PaymentNotification'
,
[
'processor_id'
=>
$this
->
_paymentProcessorID
]);
$contribution
=
$this
->
callAPISuccess
(
'
c
ontribution'
,
'get'
,
[
'id'
=>
$this
->
_contributionID
,
'sequential'
=>
1
]);
$contribution
=
$this
->
callAPISuccess
GetSingle
(
'
C
ontribution'
,
[
'id'
=>
$this
->
_contributionID
,
'sequential'
=>
1
]);
// assert that contribution is completed after getting response from paypal standard which has transaction id set and completed status
$this
->
assertEquals
(
$_REQUEST
[
'txn_id'
],
$contribution
[
'
values'
][
0
][
'
trxn_id'
]);
$this
->
assertEquals
(
$completedStatusID
,
$contribution
[
'
values'
][
0
][
'
contribution_status_id'
]);
$this
->
assertEquals
(
'test12345'
,
$contribution
[
'
values'
][
0
][
'
custom_'
.
$this
->
_customFieldID
]);
$this
->
assertEquals
(
$_REQUEST
[
'txn_id'
],
$contribution
[
'trxn_id'
]);
$this
->
assertEquals
(
$completedStatusID
,
$contribution
[
'contribution_status_id'
]);
$this
->
assertEquals
(
'test12345'
,
$contribution
[
'custom_'
.
$this
->
_customFieldID
]);
}
/**
...
...
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