From 2a84219e9c78d9cff4b8a370c0341a6b2c653274 Mon Sep 17 00:00:00 2001 From: Edsel Date: Mon, 15 Feb 2016 16:23:34 +0530 Subject: [PATCH] CRM-16259 CIVI-3 Added extra check for proportional distribution of amounts of cancelled payments ---------------------------------------- * CRM-16259: Create Payment API https://issues.civicrm.org/jira/browse/CRM-16259 --- tests/phpunit/api/v3/PaymentTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/phpunit/api/v3/PaymentTest.php b/tests/phpunit/api/v3/PaymentTest.php index 3ad33a7380..a5087f6c4f 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -394,6 +394,20 @@ class api_v3_PaymentTest extends CiviUnitTestCase { array_push(CRM_Core_Config::singleton()->userPermissionClass->permissions, 'access CiviCRM', 'edit contributions'); $payment = $this->callAPIAndDocument('payment', 'create', $params, __FUNCTION__, __FILE__); + // Check for proportional cancelled payment against lineitems. + $minParams = array( + 'entity_table' => 'civicrm_financial_item', + 'financial_trxn_id' => $payment['id'] - 1, + ); + + $eft = $this->callAPISuccess('EntityFinancialTrxn', 'get', $minParams); + $amounts = array(-33.33, -16.67); + + foreach ($eft['values'] as $value) { + $this->assertEquals($value['amount'], array_pop($amounts)); + } + + // Check for proportional updated payment against lineitems. $params = array( 'entity_table' => 'civicrm_financial_item', 'financial_trxn_id' => $payment['id'], -- 2.25.1