From 6045f2b783b025a2743272e2f337ff7b73243928 Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Fri, 6 Sep 2019 17:39:28 +0530 Subject: [PATCH] Unit test for #15166 fix --- tests/phpunit/api/v3/PaymentTest.php | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/phpunit/api/v3/PaymentTest.php b/tests/phpunit/api/v3/PaymentTest.php index 09895d9acb..b90fc7a96b 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -107,6 +107,52 @@ class api_v3_PaymentTest extends CiviUnitTestCase { ]); } + /** + * Retrieve Payment using trxn_id. + */ + public function testGetPaymentWithTrxnID() { + $this->_individualId2 = $this->individualCreate(); + $params1 = [ + 'contact_id' => $this->_individualId, + 'trxn_id' => 111111, + 'total_amount' => 10, + ]; + $contributionID1 = $this->contributionCreate($params1); + + $params2 = [ + 'contact_id' => $this->_individualId2, + 'trxn_id' => 222222, + 'total_amount' => 20, + ]; + $contributionID2 = $this->contributionCreate($params2); + + $paymentParams = ['trxn_id' => 111111]; + $payment = $this->callAPISuccess('payment', 'get', $paymentParams); + $expectedResult = [ + $payment['id'] => [ + 'total_amount' => 10, + 'trxn_id' => 111111, + 'status_id' => 1, + 'is_payment' => 1, + 'contribution_id' => $contributionID1, + ], + ]; + $this->checkPaymentResult($payment, $expectedResult); + + $paymentParams = ['trxn_id' => 222222]; + $payment = $this->callAPISuccess('payment', 'get', $paymentParams); + $expectedResult = [ + $payment['id'] => [ + 'total_amount' => 20, + 'trxn_id' => 222222, + 'status_id' => 1, + 'is_payment' => 1, + 'contribution_id' => $contributionID2, + ], + ]; + $this->checkPaymentResult($payment, $expectedResult); + } + /** * Test email receipt for partial payment. */ -- 2.25.1