From f86f083355318f45488cc50a82be213465a379ef Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 6 Jun 2019 17:55:21 +1200 Subject: [PATCH] Create payment activity when creating a payment via the api, test This is a pre-requisite for switching AdditionalPayment form to the api https://github.com/civicrm/civicrm-core/pull/14408/files --- CRM/Financial/BAO/Payment.php | 3 +-- tests/phpunit/api/v3/PaymentTest.php | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CRM/Financial/BAO/Payment.php b/CRM/Financial/BAO/Payment.php index 1683e2e31b95..96f33fd0ad35 100644 --- a/CRM/Financial/BAO/Payment.php +++ b/CRM/Financial/BAO/Payment.php @@ -102,7 +102,6 @@ public static function create($params) { } elseif ($params['total_amount'] < 0) { $trxn = self::recordRefundPayment($params['contribution_id'], $params, FALSE); - CRM_Contribute_BAO_Contribution::recordPaymentActivity($params['contribution_id'], CRM_Utils_Array::value('participant_id', $params), $params['total_amount'], $trxn->currency, $trxn->trxn_date); } if ($isPaymentCompletesContribution) { @@ -133,7 +132,7 @@ public static function create($params) { ] ); } - + CRM_Contribute_BAO_Contribution::recordPaymentActivity($params['contribution_id'], CRM_Utils_Array::value('participant_id', $params), $params['total_amount'], $trxn->currency, $trxn->trxn_date); return $trxn; } diff --git a/tests/phpunit/api/v3/PaymentTest.php b/tests/phpunit/api/v3/PaymentTest.php index 56fb75cad21c..5b3104cbe34f 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -633,7 +633,9 @@ public function testCreatePaymentPayLater() { } /** - * Test create payment api for paylater contribution with partial payment. + * Test create payment api for pay later contribution with partial payment. + * + * @throws \Exception */ public function testCreatePaymentPayLaterPartialPayment() { $this->createLoggedInUser(); @@ -717,7 +719,7 @@ public function testCreatePaymentPayLaterPartialPayment() { 'id' => $contribution['id'], ]); $this->callAPISuccess('OptionValue', 'get', ['name' => 'Completed', 'option_group_id' => 'contribution_status', 'api.OptionValue.create' => ['label' => 'Completed']]); - + $this->callAPISuccessGetCount('Activity', ['target_contact_id' => $this->_individualId, 'activity_type_id' => 'Payment'], 2); } /**