Skip to content

Commit

Permalink
Merge pull request #20301 from eileenmcnaughton/mem_move
Browse files Browse the repository at this point in the history
[REF] Remove unused parameters
  • Loading branch information
seamuslee001 authored May 19, 2021
2 parents 44bc4f0 + c92325a commit fd8f3fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
22 changes: 7 additions & 15 deletions CRM/Batch/Form/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ private function processMembership(array $params) {
'start_date' => $value['membership_start_date'] ?? NULL,
];
$membershipSource = $value['source'] ?? NULL;
[$membership] = self::legacyProcessMembership(
$membership = self::legacyProcessMembership(
$value['contact_id'], $value['membership_type_id'], FALSE,
//$numTerms should be default to 1.
NULL, NULL, $value['custom'], 1, NULL, FALSE,
Expand Down Expand Up @@ -1038,20 +1038,18 @@ public function testProcessContribution($params) {
* @param $isPayLater
* @param array $memParams
* @param array $formDates
* @param null|CRM_Contribute_BAO_Contribution $contribution
* @param array $lineItems
*
* @return array
* @return CRM_Member_BAO_Membership
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public static function legacyProcessMembership($contactID, $membershipTypeID, $is_test, $changeToday, $modifiedID, $customFieldsFormatted, $numRenewTerms, $membershipID, $pending, $contributionRecurID, $membershipSource, $isPayLater, $memParams = [], $formDates = [], $contribution = NULL, $lineItems = []) {
$renewalMode = $updateStatusId = FALSE;
public static function legacyProcessMembership($contactID, $membershipTypeID, $is_test, $changeToday, $modifiedID, $customFieldsFormatted, $numRenewTerms, $membershipID, $pending, $contributionRecurID, $membershipSource, $isPayLater, $memParams = [], $formDates = []): CRM_Member_BAO_Membership {
$updateStatusId = FALSE;
$allStatus = CRM_Member_PseudoConstant::membershipStatus();
$format = '%Y%m%d';
$statusFormat = '%Y-%m-%d';
$membershipTypeDetails = CRM_Member_BAO_MembershipType::getMembershipType($membershipTypeID);
$dates = [];
$ids = [];

// CRM-7297 - allow membership type to be be changed during renewal so long as the parent org of new membershipType
Expand All @@ -1060,7 +1058,6 @@ public static function legacyProcessMembership($contactID, $membershipTypeID, $i
$is_test, $membershipID, TRUE
);
if ($currentMembership) {
$renewalMode = TRUE;

// Do NOT do anything.
//1. membership with status : PENDING/CANCELLED (CRM-2395)
Expand All @@ -1073,11 +1070,9 @@ public static function legacyProcessMembership($contactID, $membershipTypeID, $i

$memParams = array_merge([
'id' => $currentMembership['id'],
'contribution' => $contribution,
'status_id' => $currentMembership['status_id'],
'start_date' => $currentMembership['start_date'],
'end_date' => $currentMembership['end_date'],
'line_item' => $lineItems,
'join_date' => $currentMembership['join_date'],
'membership_type_id' => $membershipTypeID,
'max_related' => !empty($membershipTypeDetails['max_related']) ? $membershipTypeDetails['max_related'] : NULL,
Expand All @@ -1087,8 +1082,7 @@ public static function legacyProcessMembership($contactID, $membershipTypeID, $i
$memParams['contribution_recur_id'] = $contributionRecurID;
}

$membership = CRM_Member_BAO_Membership::create($memParams);
return [$membership, $renewalMode, $dates];
return CRM_Member_BAO_Membership::create($memParams);
}

// Check and fix the membership if it is STALE
Expand Down Expand Up @@ -1237,19 +1231,17 @@ public static function legacyProcessMembership($contactID, $membershipTypeID, $i
}
$params['modified_id'] = $modifiedID ?? $contactID;

$memParams['contribution'] = $contribution;
$memParams['custom'] = $customFieldsFormatted;
// Load all line items & process all in membership. Don't do in contribution.
// Relevant tests in api_v3_ContributionPageTest.
$memParams['line_item'] = $lineItems;
// @todo stop passing $ids (membership and userId may be set by this point)
$membership = CRM_Member_BAO_Membership::create($memParams, $ids);

// not sure why this statement is here, seems quite odd :( - Lobo: 12/26/2010
// related to: http://forum.civicrm.org/index.php/topic,11416.msg49072.html#msg49072
$membership->find(TRUE);

return [$membership, $renewalMode, $dates];
return $membership;
}

}
10 changes: 7 additions & 3 deletions tests/phpunit/CRM/Batch/Form/EntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase {
*
* @var string
*/
protected $_membershipTypeName = NULL;
protected $_membershipTypeName;

/**
* Membership type id used in test function.
*
* @var string
*/
protected $_membershipTypeID = NULL;
protected $_membershipTypeID;

/**
* Contact id used in test function.
Expand Down Expand Up @@ -75,6 +75,10 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase {
*/
protected $_contactID4 = NULL;

/**
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function setUp(): void {
parent::setUp();

Expand Down Expand Up @@ -120,7 +124,7 @@ public function setUp(): void {
'sequential' => 1,
'visibility' => 'Public',
];
$membershipType2 = $this->callAPISuccess('membership_type', 'create', $params);
$membershipType2 = $this->callAPISuccess('MembershipType', 'create', $params);
$this->_membershipTypeID2 = $membershipType2['id'];

$this->_membershipStatusID = $this->membershipStatusCreate('test status');
Expand Down

0 comments on commit fd8f3fc

Please sign in to comment.