From: eileenmcnaugton Date: Tue, 25 Aug 2015 18:19:47 +0000 (+1200) Subject: CRM-11338 add tests for fee_amount to online contribution page X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=70cc8754c2b317251fd565ed78726c3174ec39f5;p=civicrm-core.git CRM-11338 add tests for fee_amount to online contribution page --- diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 33888d22e5..1525bcf814 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -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), ) ); } diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index ee3d429225..f5caacb335 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -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. */