CRM-20450 unit test for invoice amount
authoreileen <emcnaughton@wikimedia.org>
Mon, 24 Apr 2017 02:15:50 +0000 (14:15 +1200)
committereileen <emcnaughton@wikimedia.org>
Mon, 24 Apr 2017 02:52:36 +0000 (14:52 +1200)
CRM/Contribute/Form/Task/Invoice.php
tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php

index afa17454961f49f573a74fcb957f1ceb827a51d3..5500804b719ce71eaa3b2c8366aa7083cb2e9f30 100644 (file)
@@ -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);
         }
index caf655b415517d35bbee06bc31fe3625a0bf5c82..d18d28b068983da26ee2b0b180740b7f1fa29412 100644 (file)
@@ -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: </font></b></td>
+                  <td style = "padding-left:34px;text-align:right;"><b><font size = "1">$ 92.00</font></b></td>', $invoiceHTML[$contribution3['id']]);
+
   }
 
 }