From: Seamus Lee Date: Thu, 4 Apr 2019 06:16:58 +0000 (+1100) Subject: Fix tests and ensure that receive_date is always set X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=553842bec06fa11821ea085bbc61643e91053d4a;p=civicrm-core.git Fix tests and ensure that receive_date is always set --- diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 0f6555a26a..c7df8f5bf1 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1467,7 +1467,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { } } $now = date('YmdHis'); - $params['receive_date'] = $now; + $params['receive_date'] = date('Y-m-d H:i:s'); $params['invoice_id'] = $formValues['invoiceID']; $params['contribution_source'] = ts('%1 Membership Signup: Credit card or direct debit (by %2)', array(1 => $membershipType, 2 => $userName) @@ -1599,6 +1599,10 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $membershipTypeValues[$memType]['relate_contribution_id'] = $relateContribution; } + // @todo figure out why recieve_date isn't being set right here. + if (empty($params['receive_date'])) { + $params['receive_date'] = date('Y-m-d H:i:s'); + } $membershipParams = array_merge($params, $membershipTypeValues[$memType]); if (!empty($formValues['int_amount'])) { $init_amount = array(); diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index 4348bc26ad..f540759a3e 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -571,8 +571,7 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'membership_type_id' => array(23, $this->membershipTypeAnnualFixedID), 'record_contribution' => 1, 'total_amount' => 50, - 'receive_date' => date('m/d/Y', time()), - 'receive_date_time' => '08:36PM', + 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'), 'financial_type_id' => '2', //Member dues, see data.xml @@ -621,8 +620,7 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'record_contribution' => 1, 'status_id' => 1, 'total_amount' => 25, - 'receive_date' => date('m/d/Y', time()), - 'receive_date_time' => '08:36PM', + 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'financial_type_id' => '2', //Member dues, see data.xml 'payment_processor_id' => $this->_paymentProcessorID, @@ -669,10 +667,9 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'end_date' => '', // This format reflects the 23 being the organisation & the 25 being the type. 'membership_type_id' => array(23, $this->membershipTypeAnnualFixedID), + 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'record_contribution' => 1, 'total_amount' => $this->formatMoneyInput($partiallyPaidAmount), - 'receive_date' => date('m/d/Y', time()), - 'receive_date_time' => '08:36PM', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Partially paid'), 'financial_type_id' => '2', //Member dues, see data.xml @@ -699,8 +696,7 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'total_amount' => $this->formatMoneyInput($partiallyPaidAmount), 'currency' => 'USD', 'financial_type_id' => 2, - 'receive_date' => '04/21/2015', - 'receive_date_time' => '11:27PM', + 'receive_date' => '2015-04-21 23:27:00', 'trxn_date' => '2017-04-11 13:05:11', 'payment_processor_id' => 0, 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), @@ -1325,8 +1321,7 @@ Expires: ', 'membership_type_id' => array(23, $this->membershipTypeAnnualFixedID), 'record_contribution' => 1, 'total_amount' => 55, - 'receive_date' => date('m/d/Y', time()), - 'receive_date_time' => '08:36PM', + 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'), 'financial_type_id' => 2, //Member dues, see data.xml