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
81a53602
Unverified
Commit
81a53602
authored
3 years ago
by
Eileen McNaughton
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #20780 from eileenmcnaughton/pay_order
Fix test set up to user Order api
parents
263c21df
f34913f4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/v3/Order.php
+4
-0
4 additions, 0 deletions
api/v3/Order.php
tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php
+10
-0
10 additions, 0 deletions
tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
+16
-28
16 additions, 28 deletions
tests/phpunit/CiviTest/CiviUnitTestCase.php
with
30 additions
and
28 deletions
api/v3/Order.php
+
4
−
0
View file @
81a53602
...
...
@@ -107,9 +107,13 @@ function civicrm_api3_order_create(array $params): array {
case
'membership'
:
$entityParams
[
'status_id'
]
=
'Pending'
;
if
(
!
empty
(
$params
[
'contribution_recur_id'
]))
{
$entityParams
[
'contribution_recur_id'
]
=
$params
[
'contribution_recur_id'
];
}
$entityParams
[
'skipLineItem'
]
=
TRUE
;
$entityResult
=
civicrm_api3
(
'Membership'
,
'create'
,
$entityParams
);
break
;
}
foreach
(
$lineItems
[
'line_item'
]
as
$innerIndex
=>
$lineItem
)
{
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php
+
10
−
0
View file @
81a53602
...
...
@@ -23,6 +23,16 @@ class CRM_Core_Payment_PayPalIPNTest extends CiviUnitTestCase {
protected
$_paymentProcessorID
;
protected
$_customFieldID
;
/**
* Should financials be checked after the test but before tear down.
*
* Ideally all tests (or at least all that call any financial api calls ) should do this but there
* are some test data issues and some real bugs currently blockinng.
*
* @var bool
*/
protected
$isValidateFinancialsOnPostAssert
=
TRUE
;
/**
* Set up function.
*/
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CiviTest/CiviUnitTestCase.php
+
16
−
28
View file @
81a53602
...
...
@@ -28,6 +28,7 @@
use
Civi\Api4\CustomField
;
use
Civi\Api4\CustomGroup
;
use
Civi\Api4\LineItem
;
use
Civi\Api4\OptionGroup
;
use
Civi\Api4\RelationshipType
;
use
Civi\Payment\System
;
...
...
@@ -1058,10 +1059,8 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase {
*
* @return int
* id of created contribution
* @throws \CRM_Core_Exception
*/
public
function
contributionCreate
(
$params
)
{
public
function
contributionCreate
(
array
$params
):
int
{
$params
=
array_merge
([
'domain_id'
=>
1
,
'receive_date'
=>
date
(
'Ymd'
),
...
...
@@ -2551,10 +2550,8 @@ VALUES
*
* @param array $recurParams (Optional)
* @param array $contributionParams (Optional)
*
* @throws \CRM_Core_Exception
*/
public
function
setupRecurringPaymentProcessorTransaction
(
$recurParams
=
[],
$contributionParams
=
[])
{
public
function
setupRecurringPaymentProcessorTransaction
(
$recurParams
=
[],
$contributionParams
=
[])
:
void
{
$this
->
ids
[
'campaign'
][
0
]
=
$this
->
callAPISuccess
(
'Campaign'
,
'create'
,
[
'title'
=>
'get the money'
])[
'id'
];
$contributionParams
=
array_merge
([
'total_amount'
=>
'200'
,
...
...
@@ -2595,9 +2592,9 @@ VALUES
*
* @param array $params Optionally modify params for membership/recur (duration_unit/frequency_unit)
*
* @throws \
CRM_Core
_Exception
* @throws \
API
_Exception
*/
public
function
setupMembershipRecurringPaymentProcessorTransaction
(
$params
=
[])
{
public
function
setupMembershipRecurringPaymentProcessorTransaction
(
$params
=
[])
:
void
{
$membershipParams
=
$recurParams
=
[];
if
(
!
empty
(
$params
[
'duration_unit'
]))
{
$membershipParams
[
'duration_unit'
]
=
$params
[
'duration_unit'
];
...
...
@@ -2619,41 +2616,32 @@ VALUES
]);
}
$this
->
ids
[
'membership'
]
=
$this
->
callAPISuccess
(
'Membership'
,
'create'
,
[
'contact_id'
=>
$this
->
_contactID
,
'membership_type_id'
=>
$this
->
ids
[
'membership_type'
],
'format.only_id'
=>
TRUE
,
'source'
=>
'Payment'
,
'skipLineItem'
=>
TRUE
,
]);
$this
->
setupRecurringPaymentProcessorTransaction
(
$recurParams
,
[
'line_items'
=>
[
[
'line_item'
=>
[
[
'entity_table'
=>
'civicrm_membership'
,
'entity_id'
=>
$this
->
ids
[
'membership'
],
'label'
=>
'General'
,
'qty'
=>
1
,
'unit_price'
=>
200
,
'line_total'
=>
200
,
'financial_type_id'
=>
1
,
'price_field_id'
=>
$this
->
callAPISuccess
(
'price_field'
,
'getvalue'
,
[
'return'
=>
'id'
,
'label'
=>
'Membership Amount'
,
'options'
=>
[
'limit'
=>
1
,
'sort'
=>
'id DESC'
],
]),
'price_field_value_id'
=>
$this
->
callAPISuccess
(
'price_field_value'
,
'getvalue'
,
[
'return'
=>
'id'
,
'label'
=>
'General'
,
'options'
=>
[
'limit'
=>
1
,
'sort'
=>
'id DESC'
],
]),
'membership_type_id'
=>
$this
->
ids
[
'membership_type'
],
],
],
'params'
=>
[
'contact_id'
=>
$this
->
_contactID
,
'membership_type_id'
=>
$this
->
ids
[
'membership_type'
],
'source'
=>
'Payment'
,
],
],
],
]);
$this
->
callAPISuccess
(
'Membership'
,
'create'
,
[
'id'
=>
$this
->
ids
[
'membership'
],
'contribution_recur_id'
=>
$this
->
_contributionRecurID
]);
$this
->
ids
[
'membership'
]
=
LineItem
::
get
()
->
addWhere
(
'contribution_id'
,
'='
,
$this
->
ids
[
'Contribution'
][
0
])
->
addWhere
(
'entity_table'
,
'='
,
'civicrm_membership'
)
->
addSelect
(
'entity_id'
)
->
execute
()
->
first
()[
'entity_id'
];
}
/**
...
...
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