From b9b75df122b750b3f76982427ddcd1cfc6c615c0 Mon Sep 17 00:00:00 2001 From: Sudha Bisht Date: Thu, 11 Jun 2015 12:26:31 +0530 Subject: [PATCH] Fix for test --- CRM/Contribute/BAO/Contribution/Utils.php | 4 ++-- CRM/Member/BAO/Membership.php | 13 ++++++++----- api/v3/examples/ContributionPage/Submit.php | 1 - tests/phpunit/api/v3/ContributionPageTest.php | 1 - 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index b3449beac1..1df72627a6 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -226,8 +226,8 @@ class CRM_Contribute_BAO_Contribution_Utils { // cache the is_recur values so we can process the additional gift as a // one-off payment. $pending = FALSE; - if ($form->_membershipBlock['is_separate_payment']) { - if (!empty($form->_params['auto_renew'])) { + if (!empty($form->_values['is_recur'])) { + if ($form->_membershipBlock['is_separate_payment'] && !empty($form->_params['auto_renew'])) { $cachedFormValue = CRM_Utils_Array::value('is_recur', $form->_values); $cachedParamValue = CRM_Utils_Array::value('is_recur', $paymentParams); unset($form->_values['is_recur']); diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index b3d1ff9df9..13c2ca8c83 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -1541,7 +1541,8 @@ AND civicrm_membership.is_test = %2"; $modifiedID = NULL, $customFieldsFormatted = NULL, $numRenewTerms = 1, - $membershipID = NULL + $membershipID = NULL, + $pending = FALSE ) { $statusFormat = '%Y-%m-%d'; $format = '%Y%m%d'; @@ -1557,7 +1558,7 @@ AND civicrm_membership.is_test = %2"; $membershipTypeDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipTypeID); // check is it pending. - CRM-4555 - list($pending, $contributionRecurID, $changeToday, $membershipSource, $isPayLater, $campaignId) = self::extractFormValues($form, $changeToday, $membershipTypeDetails); + list($pending, $contributionRecurID, $changeToday, $membershipSource, $isPayLater, $campaignId) = self::extractFormValues($form, $changeToday, $membershipTypeDetails, $pending); list($membership, $renewalMode, $dates) = self::renewMembership($contactID, $membershipTypeID, $is_test, $changeToday, $modifiedID, $customFieldsFormatted, $numRenewTerms, $membershipID, $pending, $allStatus, $membershipTypeDetails, $contributionRecurID, $format, $membershipSource, $ids, $statusFormat, $isPayLater, $campaignId); $form->set('renewal_mode', $renewalMode); if (!empty($dates)) { @@ -2307,11 +2308,14 @@ INNER JOIN civicrm_contact contact ON ( contact.id = membership.contact_id AND * @return array */ public static function createOrRenewMembership($membershipParams, $contactID, $customFieldsFormatted, $membershipID, $memType, $isTest, $numTerms, $membershipContribution, &$form) { + if (!empty($membershipContribution)) { + $pending = ($membershipContribution->contribution_status_id == 2) ? TRUE : FALSE; + } $membership = self::renewMembershipFormWrapper($contactID, $memType, $isTest, $form, NULL, CRM_Utils_Array::value('cms_contactID', $membershipParams), $customFieldsFormatted, $numTerms, - $membershipID + $membershipID, $pending ); if (!empty($membershipContribution)) { @@ -2348,8 +2352,7 @@ INNER JOIN civicrm_contact contact ON ( contact.id = membership.contact_id AND * * @return array */ - public static function extractFormValues($form, $changeToday, $membershipTypeDetails) { - $pending = FALSE; + public static function extractFormValues($form, $changeToday, $membershipTypeDetails, $pending = FALSE) { //@todo this is a BAO function & should not inspect the form - the form should do this // & pass required params to the BAO if (CRM_Utils_Array::value('minimum_fee', $membershipTypeDetails) > 0.0) { diff --git a/api/v3/examples/ContributionPage/Submit.php b/api/v3/examples/ContributionPage/Submit.php index e48416e567..aa56052703 100644 --- a/api/v3/examples/ContributionPage/Submit.php +++ b/api/v3/examples/ContributionPage/Submit.php @@ -30,7 +30,6 @@ function contribution_page_submit_example() { 'is_recur' => 1, 'frequency_interval' => 1, 'frequency_unit' => 'month', - 'is_pay_later' => 1, ); try{ diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index 2051df4ee9..62267179d0 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -349,7 +349,6 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { 'is_recur' => 1, 'frequency_interval' => 1, 'frequency_unit' => 'month', - 'is_pay_later' => 1, ); $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL); -- 2.25.1