From 371e0262615ec3057b1a8482b66866a7784b375c Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Fri, 29 Dec 2017 11:42:02 +0530 Subject: [PATCH] CRM-21612: Membership Payment not recorded for recurring contribution when status label is changed --- CRM/Core/Payment.php | 2 +- .../phpunit/CRM/Member/Form/MembershipTest.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 80879d97db..a5970075ed 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -1158,7 +1158,7 @@ abstract class CRM_Core_Payment { */ public function doPayment(&$params, $component = 'contribute') { $this->_component = $component; - $statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id'); + $statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'validate'); // If we have a $0 amount, skip call to processor and set payment_status to Completed. // Conceivably a processor might override this - perhaps for setting up a token - but we don't diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index 01868caba5..41463c1450 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -689,6 +689,17 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * Test the submit function of the membership form. */ public function testSubmitRecur() { + $pendingVal = $this->callAPISuccessGetValue('OptionValue', array( + 'return' => "id", + 'option_group_id' => "contribution_status", + 'label' => "Pending", + )); + //Update label for Pending contribution status. + $this->callAPISuccess('OptionValue', 'create', array( + 'id' => $pendingVal, + 'label' => "PendingEdited", + )); + $form = $this->getForm(); $this->callAPISuccess('MembershipType', 'create', array( @@ -711,6 +722,12 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'is_test' => TRUE, )); + //Check if Membership Payment is recorded. + $this->callAPISuccessGetCount('MembershipPayment', array( + 'membership_id' => $membership['id'], + 'contribution_id' => $contribution['id'], + ), 1); + // CRM-16992. $this->callAPISuccessGetCount('LineItem', array( 'entity_id' => $membership['id'], -- 2.25.1