CRM-11338 add tests for fee_amount to online contribution page
authoreileenmcnaugton <eileen@fuzion.co.nz>
Tue, 25 Aug 2015 18:19:47 +0000 (06:19 +1200)
committereileenmcnaugton <eileen@fuzion.co.nz>
Tue, 25 Aug 2015 19:26:57 +0000 (07:26 +1200)
CRM/Contribute/Form/Contribution/Confirm.php
tests/phpunit/api/v3/ContributionPageTest.php

index 33888d22e5a953a7e7b99e214c52c69fea95f8af..1525bcf814cb9db259804fe459851634c184f79d 100644 (file)
@@ -2288,6 +2288,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
               'trxn_id' => CRM_Utils_Array::value('trxn_id', $result),
               'payment_processor_id' => $this->_paymentProcessor['id'],
               'is_transactional' => FALSE,
+              'fee_amount' => CRM_Utils_Array::value('fee_amount', $result),
             )
           );
         }
index ee3d429225b50172bfef94f773089d0616ce646f..f5caacb335cf67863bca614363cac373cadc0580 100644 (file)
@@ -164,7 +164,11 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
       'billing_mode' => 1,
     ));
     $dummyPP = Civi\Payment\System::singleton()->getById($paymentProcessor2ID);
-    $dummyPP->setDoDirectPaymentResult(array('payment_status_id' => 1, 'trxn_id' => 'create_first_success'));
+    $dummyPP->setDoDirectPaymentResult(array(
+      'payment_status_id' => 1,
+      'trxn_id' => 'create_first_success',
+      'fee_amount' => .85,
+    ));
     $this->callAPISuccess('ContributionPage', 'create', array(
       'id' => $this->_ids['contribution_page'],
       'payment_processor' => array($paymentProcessor2ID, $this->_ids['payment_processor']),
@@ -183,11 +187,16 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
     );
 
     $this->callAPISuccess('contribution_page', 'submit', $submitParams);
-    $this->callAPISuccess('contribution', 'getsingle', array(
+    $contribution = $this->callAPISuccess('contribution', 'getsingle', array(
       'contribution_page_id' => $this->_ids['contribution_page'],
       'contribution_status_id' => 1,
     ));
+    $this->assertEquals('create_first_success', $contribution['trxn_id']);
+    $this->assertEquals(10, $contribution['total_amount']);
+    $this->assertEquals(.85, $contribution['fee_amount']);
+    $this->assertEquals(9.15, $contribution['net_amount']);
   }
+
   /**
    * Test submit with a membership block in place.
    */