CRM-14151 add hacky-handling to receive date like other date fields in completetransa...
authorEileen McNaughton <eileen@fuzion.co.nz>
Fri, 31 Jan 2014 20:12:42 +0000 (09:12 +1300)
committerEileen McNaughton <eileen@fuzion.co.nz>
Fri, 31 Jan 2014 20:12:42 +0000 (09:12 +1300)
----------------------------------------
* CRM-14151: BaseIPN fails when receipt_date is set
  http://issues.civicrm.org/jira/browse/CRM-14151

CRM/Core/Payment/BaseIPN.php
tests/phpunit/api/v3/ContributionTest.php

index eeff13606e4ab324529bfe94b67259c20b0c015f..3976560052fb1a937debca4a8caadf044746a742 100644 (file)
@@ -502,6 +502,7 @@ LIMIT 1;";
     $contribution->trxn_id = $input['trxn_id'];
     $contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date);
     $contribution->thankyou_date = CRM_Utils_Date::isoToMysql($contribution->thankyou_date);
+    $contribution->receipt_date = CRM_Utils_Date::isoToMysql($contribution->receipt_date);
     $contribution->cancel_date = 'null';
 
     if (CRM_Utils_Array::value('check_number', $input)) {
index c05465c93185a85f1faa8af2d6571371c0c9a119..df1ccfac77b3406f27214950b0935f62075af19f 100644 (file)
@@ -1230,6 +1230,31 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
     $mut->stop();
   }
 
+  /**
+   * CRM-14151
+   * Test completing a transaction via the API
+   *
+   * For wierd caching-y reasons this test performs differently in isolation than with other
+   * tests.
+   */
+  function testCompleteTransactionWithReceiptDateSet() {
+    $mut = new CiviMailUtils( $this, true );
+    $this->createLoggedInUser();
+    $params = array_merge($this->_params, array('contribution_status_id' => 1,'receipt_date' => 'now'));
+    $contribution = $this->callAPISuccess('contribution','create', $params);
+    $apiResult = $this->callAPISuccess('contribution', 'completetransaction', array(
+      'id' => $contribution['id'],
+    )
+    );
+    $contribution = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id'], 'sequential' => 1,));
+    $this->assertEquals('Completed', $contribution['values'][0]['contribution_status']);
+    $mut->checkMailLog(array(
+      'Receipt - Contribution',
+      'Please print this confirmation for your records.',
+    ));
+    $mut->stop();
+  }
+
   /**
    * Test completing a transaction with an event via the API
    *