From: Eileen McNaughton Date: Fri, 31 Jan 2014 20:12:42 +0000 (+1300) Subject: CRM-14151 add hacky-handling to receive date like other date fields in completetransa... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=46fa5206ed483f29fca6a510fbc328a99cb961a6;p=civicrm-core.git CRM-14151 add hacky-handling to receive date like other date fields in completetransaction function to mitigate DAO->find() followed by DAO->save() fatalling on date fields .. sometimes ---------------------------------------- * CRM-14151: BaseIPN fails when receipt_date is set http://issues.civicrm.org/jira/browse/CRM-14151 --- diff --git a/CRM/Core/Payment/BaseIPN.php b/CRM/Core/Payment/BaseIPN.php index eeff13606e..3976560052 100644 --- a/CRM/Core/Payment/BaseIPN.php +++ b/CRM/Core/Payment/BaseIPN.php @@ -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)) { diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index c05465c931..df1ccfac77 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -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 *