From c3af113510315c1730924c66652b33d62171647c Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Tue, 24 Oct 2017 15:06:15 +0530 Subject: [PATCH] Revert #10093 skip status calculation when form dates are not modified --- CRM/Member/Form/Membership.php | 11 ----- .../CRM/Member/Form/MembershipTest.php | 43 ------------------- 2 files changed, 54 deletions(-) diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index e6f5c984ee..acb14746d6 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1201,20 +1201,9 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { 'start_date' => 'startDate', 'end_date' => 'endDate', ); - $dateModified = FALSE; foreach ($dateTypes as $dateField => $dateVariable) { - if (!empty($params['id'])) { - $membershipDate = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $params['id'], $dateField, 'id'); - if ($membershipDate != date('Y-m-d', strtotime($formValues[$dateField]))) { - $dateModified = TRUE; - } - } $$dateVariable = CRM_Utils_Date::processDate($formValues[$dateField]); } - //skip status calculation on update if none of the dates are modified. - if (!empty($params['id']) && empty($params['is_override']) && !$dateModified) { - $params['skipStatusCal'] = TRUE; - } $memTypeNumTerms = empty($termsByType) ? CRM_Utils_Array::value('num_terms', $formValues) : NULL; diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index c43ac6e039..58b1e72b6a 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -714,49 +714,6 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { ), 1); } - /** - * Test membership form with Failed Contribution. - */ - public function testFormStatusUpdate() { - $form = $this->getForm(); - $form->preProcess(); - $this->_individualId = $this->createLoggedInUser(); - $memParams = array( - 'contact_id' => $this->_individualId, - 'membership_type_id' => $this->membershipTypeAnnualFixedID, - 'is_override' => TRUE, - 'status_id' => array_search('Cancelled', CRM_Member_PseudoConstant::membershipStatus()), - ); - $params = $this->getBaseSubmitParams(); - $params['id'] = $this->contactMembershipCreate($memParams); - unset($params['price_set_id']); - unset($params['credit_card_number']); - unset($params['cvv2']); - unset($params['credit_card_exp_date']); - unset($params['credit_card_type']); - unset($params['send_receipt']); - unset($params['is_recur']); - - // process date params to mysql date format. - $dateTypes = array( - 'join_date' => 'joinDate', - 'start_date' => 'startDate', - 'end_date' => 'endDate', - ); - $previousStatus = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $params['id'], 'status_id'); - foreach ($dateTypes as $dateField => $dateVariable) { - $params[$dateField] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $params['id'], $dateField); - } - $form->_id = $params['id']; - $form->_mode = NULL; - $form->_contactID = $this->_individualId; - - $form->testSubmit($params); - $membership = $this->callAPISuccessGetSingle('Membership', array('contact_id' => $this->_individualId)); - //Assert the status remains when the form dates are not modified. - $this->assertEquals($membership['status_id'], $previousStatus); - } - /** * CRM-20946: Test the financial entires especially the reversed amount, * after related Contribution is cancelled -- 2.25.1