CRM-19585, added test for getSalesTaxFinancialAccounts()
authorPradeep Nayak <pradpnayak@gmail.com>
Tue, 3 Jan 2017 13:32:52 +0000 (19:02 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Tue, 3 Jan 2017 13:32:52 +0000 (19:02 +0530)
----------------------------------------
* CRM-19585: Sales tax issue
  https://issues.civicrm.org/jira/browse/CRM-19585

tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
tests/phpunit/CiviTest/CiviUnitTestCase.php

index d2f13ef4159bc8ff28fc5a5b8ee156a51961e003..c2b0545f5a8e14296176fb7d9249e5cde193b3a4 100644 (file)
@@ -1069,4 +1069,19 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2";
     $this->assertEquals($financialTrxn['total_amount'], 8000, 'Invalid Tax amount.');
   }
 
+  /**
+   * Test for function getSalesTaxFinancialAccounts().
+   */
+  public function testgetSalesTaxFinancialAccounts() {
+    $this->enableTaxAndInvoicing();
+    $financialType = $this->createFinancialType();
+    $financialAccount = $this->relationForFinancialTypeWithFinancialAccount($financialType['id']);
+    $expectedResult = array($financialAccount->financial_account_id => $financialAccount->financial_account_id);
+    $financialType = $this->createFinancialType();
+    $financialAccount = $this->relationForFinancialTypeWithFinancialAccount($financialType['id']);
+    $expectedResult[$financialAccount->financial_account_id] = $financialAccount->financial_account_id;
+    $salesTaxFinancialAccount = CRM_Contribute_BAO_Contribution::getSalesTaxFinancialAccounts();
+    $this->assertTrue(($salesTaxFinancialAccount == $expectedResult), 'Function returned wrong values.');
+  }
+
 }
index 296dc5ec7d3b4994586cb0bf66dbe11c2b0c7fc8..c4aba681eea50a8fdd74c6f600fbca6d8714aac8 100644 (file)
@@ -3629,6 +3629,23 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
     }
   }
 
+  /**
+   * Create Financial Type.
+   *
+   * @param array $params
+   *
+   * @return array
+   */
+  protected function createFinancialType($params = array()) {
+    $params = array_merge($params,
+      array(
+        'name' => 'Financial-Type -' . substr(sha1(rand()), 0, 7),
+        'is_active' => 1,
+      )
+    );
+    return $this->callAPISuccess('FinancialType', 'create', $params);
+  }
+
   /**
    * Enable Tax and Invoicing
    */