Fix tests and ensure that receive_date is always set
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 4 Apr 2019 06:16:58 +0000 (17:16 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 4 Apr 2019 06:16:58 +0000 (17:16 +1100)
CRM/Member/Form/Membership.php
tests/phpunit/CRM/Member/Form/MembershipTest.php

index 0f6555a26a3b0a37a2c961901342c512961097b9..c7df8f5bf1ffe0293452b9922bb837b9af71c2b2 100644 (file)
@@ -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();
index 4348bc26adc9908830584afb09c1e55bf850c78c..f540759a3e90c980cdd050a6f2457fcb46929a53 100644 (file)
@@ -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