X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FCiviTest%2FCiviUnitTestCase.php;h=54fb3746d96846512d6a5e701b6c01dc272b20c7;hb=dc7f057aa1428750d240634af100a20a11ab9cbe;hp=429249e2bde6284fe6523863db54285e737801c6;hpb=ea3ea59465830045112ce3030a0b2cc78ab92f47;p=civicrm-core.git diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 429249e2bd..54fb3746d9 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -2504,6 +2504,7 @@ VALUES * @throws \CRM_Core_Exception */ public function setupRecurringPaymentProcessorTransaction($recurParams = [], $contributionParams = []) { + $this->ids['campaign'][0] = $this->callAPISuccess('Campaign', 'create', ['title' => 'get the money'])['id']; $contributionParams = array_merge([ 'total_amount' => '200', 'invoice_id' => $this->_invoiceID, @@ -2515,6 +2516,9 @@ VALUES 'is_test' => 0, 'receive_date' => '2019-07-25 07:34:23', 'skipCleanMoney' => TRUE, + 'amount_level' => 'expensive', + 'campaign_id' => $this->ids['campaign'][0], + 'source' => 'Online Contribution: Page name', ], $contributionParams); $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array_merge([ 'contact_id' => $this->_contactID, @@ -3088,21 +3092,24 @@ VALUES } /** - * Add Sales Tax relation for financial type with financial account. + * Add Sales Tax Account for the financial type. * * @param int $financialTypeId * - * @return obj + * @param array $accountParams + * + * @return CRM_Financial_DAO_EntityFinancialAccount + * @throws \CRM_Core_Exception */ - protected function relationForFinancialTypeWithFinancialAccount($financialTypeId) { - $params = [ + protected function addTaxAccountToFinancialType(int $financialTypeId, $accountParams = []) { + $params = array_merge([ 'name' => 'Sales tax account ' . substr(sha1(rand()), 0, 4), 'financial_account_type_id' => key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name LIKE 'Liability' ")), 'is_deductible' => 1, 'is_tax' => 1, 'tax_rate' => 10, 'is_active' => 1, - ]; + ], $accountParams); $account = CRM_Financial_BAO_FinancialAccount::add($params); $entityParams = [ 'entity_table' => 'civicrm_financial_type', @@ -3111,7 +3118,7 @@ VALUES ]; // set tax rate (as 10) for provided financial type ID to static variable, later used to fetch tax rates of all financial types - \Civi::$statics['CRM_Core_PseudoConstant']['taxRates'][$financialTypeId] = 10; + \Civi::$statics['CRM_Core_PseudoConstant']['taxRates'][$financialTypeId] = $params['tax_rate']; //CRM-20313: As per unique index added in civicrm_entity_financial_account table, // first check if there's any record on basis of unique key (entity_table, account_relationship, entity_id)