From fd9e1183862c7ccf31f683936ee2493493965764 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 24 Apr 2017 14:15:50 +1200 Subject: [PATCH] CRM-20450 unit test for invoice amount --- CRM/Contribute/Form/Task/Invoice.php | 4 ++-- tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index afa1745496..5500804b71 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -286,7 +286,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { // to get billing address if present $billingAddress = array(); - foreach ($addressDetails as $key => $address) { + foreach ($addressDetails as $address) { if ((isset($address['is_billing']) && $address['is_billing'] == 1) && (isset($address['is_primary']) && $address['is_primary'] == 1) && $address['contact_id'] == $contribution->contact_id) { $billingAddress[$address['contact_id']] = $address; break; @@ -343,7 +343,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { // retrieving the subtotal and sum of same tax_rate $dataArray = array(); $subTotal = 0; - foreach ($lineItem as $entity_id => $taxRate) { + foreach ($lineItem as $taxRate) { if (isset($dataArray[(string) $taxRate['tax_rate']])) { $dataArray[(string) $taxRate['tax_rate']] = $dataArray[(string) $taxRate['tax_rate']] + CRM_Utils_Array::value('tax_amount', $taxRate); } diff --git a/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php index caf655b415..d18d28b068 100644 --- a/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php @@ -69,9 +69,15 @@ class CRM_Contribute_Form_Task_InvoiceTest extends CiviUnitTestCase { $contributionParams['is_pay_later'] = 1; $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams); + $contribution3 = $this->callAPISuccess('Contribution', 'create', $contributionParams); + $this->callAPISuccess('Payment', 'create', array('total_amount' => 8, 'contribution_id' => $contribution3['id'])); + + $this->callAPISuccess('Contribution', 'create', array('id' => $contribution3['id'], 'is_pay_later' => 0)); + $contributionIDs = array( array($result['id']), array($contribution['id']), + array($contribution3['id']), ); $contactIds[] = $this->_individualId; @@ -85,6 +91,9 @@ class CRM_Contribute_Form_Task_InvoiceTest extends CiviUnitTestCase { $this->assertContains('Due Date', $invoiceHTML[$contribution['id']]); $this->assertContains('PAYMENT ADVICE', $invoiceHTML[$contribution['id']]); + $this->assertContains('AMOUNT DUE: + $ 92.00', $invoiceHTML[$contribution3['id']]); + } } -- 2.25.1