CRM-16189, added full stop and used callAPISuccess() to create entries in db
authorPradeep Nayak <pradpnayak@gmail.com>
Wed, 22 Jun 2016 09:42:48 +0000 (15:12 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Thu, 23 Jun 2016 17:43:13 +0000 (23:13 +0530)
----------------------------------------
* CRM-16189: Improve support for Accrual Method bookkeeping
  https://issues.civicrm.org/jira/browse/CRM-16189

Conflicts:

CRM/Financial/BAO/FinancialAccount.php

CRM/Financial/BAO/FinancialAccount.php
tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php

index defff9a1badd147e25e37b2b575c95dab5eeacac..64aa86879b55b43d4eb1bc2817869fc13d4117c1 100644 (file)
@@ -247,7 +247,7 @@ WHERE cft.id = %1
   }
 
   /**
-   * Get Financial Account type relations
+   * Get Financial Account type relations.
    *
    * @param $flip bool
    *
@@ -283,7 +283,7 @@ WHERE cft.id = %1
   }
 
   /**
-   * Get Deferred Financial type
+   * Get Deferred Financial type.
    *
    * @return array
    *
index 424416f30340f731ffaaf2cc1aac7dbf775e8a0d..5f52bd7c4497ab8df8aac9362d27bd9c4aac4188 100644 (file)
@@ -227,27 +227,26 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase {
       'is_reserved' => 0,
     );
 
-    $ids = array();
-    $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
+    $financialAccount = $this->callAPISuccess('FinancialAccount', 'create', $params);
     $params['name'] = 'test_financialType1';
-    $financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
+    $financialType = $this->callAPISuccess('FinancialType', 'create', $params);
     $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Deferred Revenue Account is' "));
     $financialParams = array(
       'entity_table' => 'civicrm_financial_type',
-      'entity_id' => $financialType->id,
+      'entity_id' => $financialType['id'],
       'account_relationship' => $relationTypeId,
-      'financial_account_id' => $financialAccount->id,
+      'financial_account_id' => $financialAccount['id'],
     );
 
-    CRM_Financial_BAO_FinancialTypeAccount::add($financialParams, $ids);
+    $this->callAPISuccess('EntityFinancialAccount', 'create', $financialParams);
     $result = $this->assertDBNotNull(
       'CRM_Financial_DAO_EntityFinancialAccount',
-      $financialAccount->id,
+      $financialAccount['id'],
       'entity_id',
       'financial_account_id',
       'Database check on added financial type record.'
     );
-    $this->assertEquals($result, $financialType->id, 'Verify Account Type');
+    $this->assertEquals($result, $financialType['id'], 'Verify Account Type');
     $financialTypes = CRM_Financial_BAO_FinancialAccount::getDeferredFinancialType();
     $this->assertTrue(array_key_exists($result, $financialTypes), "The financial type created does not have a deferred account relationship");
   }