CRM-16259 CIVI-3 Added extra check for proportional distribution of amounts of cancel...
authorEdsel <edsel.lopez@jmaconsulting.biz>
Mon, 15 Feb 2016 10:53:34 +0000 (16:23 +0530)
committerEdsel <edsel.lopez@jmaconsulting.biz>
Tue, 16 Feb 2016 07:29:16 +0000 (12:59 +0530)
----------------------------------------
* CRM-16259: Create Payment API
  https://issues.civicrm.org/jira/browse/CRM-16259

tests/phpunit/api/v3/PaymentTest.php

index 3ad33a73801cbd4b6d8bcc5b56692fc53645ae43..a5087f6c4f75dc56a10b9f622c927defc04dff2d 100644 (file)
@@ -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'],