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
e8a645ac
Commit
e8a645ac
authored
4 years ago
by
eileen
Browse files
Options
Downloads
Patches
Plain Diff
[Test] Extend new membership form to cover multi-line renew
parent
efbd9747
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Member/Form.php
+1
-1
1 addition, 1 deletion
CRM/Member/Form.php
tests/phpunit/CRM/Member/Form/MembershipTest.php
+32
-7
32 additions, 7 deletions
tests/phpunit/CRM/Member/Form/MembershipTest.php
with
33 additions
and
8 deletions
CRM/Member/Form.php
+
1
−
1
View file @
e8a645ac
...
...
@@ -466,7 +466,7 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment {
*
* @param array $formValues
*/
public
function
testSubmit
(
$formValues
)
{
public
function
testSubmit
(
array
$formValues
)
:
void
{
$this
->
setContextVariables
(
$formValues
);
$this
->
_memType
=
$formValues
[
'membership_type_id'
][
1
];
$this
->
_params
=
$formValues
;
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CRM/Member/Form/MembershipTest.php
+
32
−
7
View file @
e8a645ac
...
...
@@ -769,17 +769,15 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase {
'label'
=>
'PendingEdited'
,
]);
$form
=
$this
->
getForm
();
$this
->
callAPISuccess
(
'MembershipType'
,
'create'
,
[
'id'
=>
$this
->
ids
[
'membership_type'
][
'AnnualFixed'
],
'duration_unit'
=>
'month'
,
'duration_interval'
=>
1
,
'auto_renew'
=>
TRUE
,
]);
$form
->
preProcess
();
$this
->
createLoggedInUser
();
$params
=
$this
->
getBaseSubmitParams
();
$form
=
$this
->
getForm
();
$this
->
createLoggedInUser
();
$form
->
_mode
=
'test'
;
$form
->
_contactID
=
$this
->
_individualId
;
$form
->
testSubmit
(
$params
);
...
...
@@ -813,9 +811,33 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase {
],
CRM_Core_Session
::
singleton
()
->
getStatus
());
}
public
function
testSubmitRecurTwoRows
()
{
$this
->
createMembershipPriceSet
();
/**
* Test submit recurring with two line items.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public
function
testSubmitRecurTwoRows
():
void
{
$pfvIDs
=
$this
->
createMembershipPriceSet
();
$form
=
$this
->
getForm
();
$form
->
_mode
=
'live'
;
$priceParams
=
[
'price_'
.
$this
->
getPriceFieldID
()
=>
$pfvIDs
,
'price_set_id'
=>
$this
->
getPriceSetID
(),
'frequency_interval'
=>
1
,
'frequency_unit'
=>
'month'
,
'membership_type_id'
=>
NULL
,
];
$form
->
testSubmit
(
array_merge
(
$this
->
getBaseSubmitParams
(),
$priceParams
));
$memberships
=
$this
->
callAPISuccess
(
'Membership'
,
'get'
)[
'values'
];
$this
->
assertCount
(
2
,
$memberships
);
$this
->
callAPISuccessGetSingle
(
'Contribution'
,
[]);
$this
->
callAPISuccessGetCount
(
'MembershipPayment'
,
[],
2
);
$lines
=
$this
->
callAPISuccess
(
'LineItem'
,
'get'
,
[
'sequential'
=>
1
])[
'values'
];
$this
->
assertCount
(
2
,
$lines
);
$this
->
assertEquals
(
'civicrm_membership'
,
$lines
[
0
][
'entity_table'
]);
$this
->
assertEquals
(
'civicrm_membership'
,
$lines
[
1
][
'entity_table'
]);
}
/**
...
...
@@ -1177,10 +1199,12 @@ Expires: ',
/**
* Get a membership form object.
*
* We need to instantiate the form to run preprocess, which means we have to trick it about the request method.
* We need to instantiate the form to run preprocess, which means we have to
* trick it about the request method.
*
* @return \CRM_Member_Form_Membership
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
protected
function
getForm
()
{
if
(
isset
(
$_REQUEST
[
'cid'
]))
{
...
...
@@ -1189,6 +1213,7 @@ Expires: ',
$form
=
new
CRM_Member_Form_Membership
();
$_SERVER
[
'REQUEST_METHOD'
]
=
'GET'
;
$form
->
controller
=
new
CRM_Core_Controller
();
$form
->
preProcess
();
return
$form
;
}
...
...
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