From 06a2050e97a0cd3446a2f5e37bde8aea05ff0639 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 13 Jan 2020 08:51:23 +1100 Subject: [PATCH] [REF] Fix return value on deleting financial type Extend unit test to cover deleting fin type --- CRM/Financial/BAO/FinancialType.php | 2 +- CRM/Financial/Form/FinancialType.php | 2 +- tests/phpunit/api/v3/FinancialTypeTest.php | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index bd695bb584..c551d67529 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -153,7 +153,7 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { $entityFinancialType->entity_id = $financialTypeId; $entityFinancialType->entity_table = 'civicrm_financial_type'; $entityFinancialType->delete(); - return FALSE; + return TRUE; } /** diff --git a/CRM/Financial/Form/FinancialType.php b/CRM/Financial/Form/FinancialType.php index 9dd624538c..2e5e1ea46b 100644 --- a/CRM/Financial/Form/FinancialType.php +++ b/CRM/Financial/Form/FinancialType.php @@ -118,7 +118,7 @@ class CRM_Financial_Form_FinancialType extends CRM_Contribute_Form { public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { $errors = CRM_Financial_BAO_FinancialType::del($this->_id); - if (!empty($errors)) { + if (is_array($errors) && !empty($errors)) { CRM_Core_Error::statusBounce($errors['error_message'], CRM_Utils_System::url('civicrm/admin/financial/financialType', "reset=1&action=browse"), ts('Cannot Delete')); } CRM_Core_Session::setStatus(ts('Selected financial type has been deleted.'), ts('Record Deleted'), 'success'); diff --git a/tests/phpunit/api/v3/FinancialTypeTest.php b/tests/phpunit/api/v3/FinancialTypeTest.php index 56ba907e8d..402dec1d38 100644 --- a/tests/phpunit/api/v3/FinancialTypeTest.php +++ b/tests/phpunit/api/v3/FinancialTypeTest.php @@ -86,6 +86,7 @@ class api_v3_FinancialTypeTest extends CiviUnitTestCase { $this->callAPISuccessGetSingle('FinancialType', [ 'id' => $financialType['id'], ], $expectedResult); + $this->callAPISuccess('FinancialType', 'delete', ['id' => $financialType['id']]); } } -- 2.25.1