From: Pradeep Nayak Date: Tue, 1 Nov 2016 12:21:41 +0000 (+0530) Subject: CRM-19587, Added test X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b4ea7992f716dab78c1e6baad414ea15477d107e;p=civicrm-core.git CRM-19587, Added test ---------------------------------------- * CRM-19587: DB Error when trying to delete FInancial Account https://issues.civicrm.org/jira/browse/CRM-19587 --- diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php index 9a31b1c3a6..f2fb46402e 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php @@ -119,6 +119,39 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase { $this->assertEquals(empty($result), TRUE, 'Verify financial types record deletion.'); } + /** + * Check method del() + */ + public function testdelIfHasContribution() { + $params = array( + 'name' => 'Donation Test', + 'is_active' => 1, + 'is_deductible' => 1, + 'is_reserved' => 1, + ); + $financialType = CRM_Financial_BAO_FinancialType::add($params); + $defaults = array(); + $params = array( + 'name' => 'Donation Test', + 'is_active' => 1, + ); + $result = CRM_Financial_BAO_FinancialAccount::retrieve($params, $defaults); + + $contactId = $this->individualCreate(); + $contributionParams = array( + 'total_amount' => 300, + 'currency' => 'USD', + 'contact_id' => $contactId, + 'financial_type_id' => $financialType->id, + 'contribution_status_id' => 1, + ); + $contributions = CRM_Contribute_BAO_Contribution::create($contributionParams); + CRM_Financial_BAO_FinancialAccount::del($result->id); + $params = array('id' => $result->id); + $result = CRM_Financial_BAO_FinancialAccount::retrieve($params, $defaults); + $this->assertEquals(empty($result), FALSE, 'Verify financial account record deletion.'); + } + /** * Check method getAccountingCode() */