Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Consolidate code in processMembership #17611

Merged
merged 1 commit into from
Jun 19, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Jun 14, 2020

Overview

Code cleanup

Now we have test cover from #17605 and other
recents we can consolidate this code & be comfortable the test cover will pick up issues.

Before

Duplicated & unnecessary code

After

33 less lines of it!

Technical Details

I added test cover here before touching it!

Comments

@civibot
Copy link

civibot bot commented Jun 14, 2020

(Standard links)

@civibot civibot bot added the master label Jun 14, 2020
@@ -787,54 +785,29 @@ public function processMembership($contactID, $membershipTypeID, $is_test, $chan
// Check and fix the membership if it is STALE
CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeToday);

// CRM-7297 Membership Upsell - calculate dates based on new membership type
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these have been moved outside the if below as they are the same in both places

//set the log start date.
$memParams['log_start_date'] = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);

if (empty($membership->source)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gone - tests show unneeded

$memParams['membership_type_id'] = $membershipTypeID;

//set the log start date.
$memParams['log_start_date'] = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gone - tests show unneeded


// Insert renewed dates for CURRENT membership
$memParams = [];
$memParams['join_date'] = $membership->join_date;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gone - tests show unneeded

$currentMembership[$dateType] = $dates[$dateType] ?? NULL;
}
$currentMembership['is_test'] = $is_test;
$memParams = $currentMembership;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gone - tests show unneeded

@@ -847,12 +820,6 @@ public function processMembership($contactID, $membershipTypeID, $is_test, $chan
$memParams['contribution_recur_id'] = $contributionRecurID;
}

//since we are renewing,
//make status override false.
$memParams['is_override'] = FALSE;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved up

@seamuslee001
Copy link
Contributor

Test fail related

@seamuslee001
Copy link
Contributor

@eileenmcnaughton PHP Parse error: syntax error, unexpected '=', expecting ']' in CRM/Member/Form/MembershipRenewal.php on line 798

Now we have test cover from civicrm#17605 and other
recents we can consolidate this code & be comfortable the test cover will pick up issues.
@mlutfy
Copy link
Member

mlutfy commented Jun 16, 2020

Seems good:

  • Did a code review, resulting code is more clear
  • Tests are passing

@mlutfy mlutfy added the merge ready PR will be merged after a few days if there are no objections label Jun 16, 2020
@seamuslee001
Copy link
Contributor

This has been merge ready for a couple of days now, no one has objected merging

@seamuslee001 seamuslee001 merged commit bc24c42 into civicrm:master Jun 19, 2020
@seamuslee001 seamuslee001 deleted the renew branch June 19, 2020 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants