CRM-15960 test
authorEileen McNaughton <eileen@fuzion.co.nz>
Thu, 12 Feb 2015 05:40:10 +0000 (18:40 +1300)
committerEileen McNaughton <eileen@fuzion.co.nz>
Thu, 12 Feb 2015 05:40:10 +0000 (18:40 +1300)
tests/phpunit/api/v3/ContributionTest.php

index 6f81b00bb5ac0ed1601d5d1016d678d3a7bd0d02..c35994f60a86f3422696e83aa1f4e583accf6a63 100644 (file)
@@ -1323,6 +1323,22 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
     $mut->stop();
   }
 
+  /**
+   * Test completing a transaction does not 'mess' with net amount (CRM-15960).
+   */
+  public function testCompleteTransactionNetAmountOK() {
+    $this->createLoggedInUser();
+    $params = array_merge($this->_params, array('contribution_status_id' => 2));
+    unset($params['net_amount']);
+    $contribution = $this->callAPISuccess('contribution', 'create', $params);
+    $this->callAPISuccess('contribution', 'completetransaction', array(
+      'id' => $contribution['id'],
+    ));
+    $contribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => $contribution['id']));
+    $this->assertEquals('Completed', $contribution['contribution_status']);
+    $this->assertTrue(($contribution['total_amount'] - $contribution['net_amount']) == $contribution['fee_amount']);
+  }
+
   /**
    * CRM-14151
    * Test completing a transaction via the API