From 9611f1f255b203eff505eabdf1a5e401f6daa6d8 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Sun, 15 Mar 2020 18:57:24 -0400 Subject: [PATCH] make case type required for change case type activity instead of a preprocess check that doesn't work --- CRM/Case/Form/Activity.php | 11 ----------- CRM/Case/Form/Activity/ChangeCaseType.php | 2 +- tests/phpunit/CRM/Core/FormTest.php | 8 ++++++++ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CRM/Case/Form/Activity.php b/CRM/Case/Form/Activity.php index 219fa7dc05..2b3f1ee862 100644 --- a/CRM/Case/Form/Activity.php +++ b/CRM/Case/Form/Activity.php @@ -145,17 +145,6 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { ); } if (!$this->_activityId) { - $caseTypes = CRM_Case_PseudoConstant::caseType(); - - if (empty($caseTypes) && ($this->_activityTypeName == 'Change Case Type') && !$this->_caseId) { - $url = CRM_Utils_System::url('civicrm/contact/view/case', - "reset=1&action=view&cid={$this->_currentlyViewedContactId}&id={$caseIds}&show=1" - ); - $session = CRM_Core_Session::singleton(); - $session->pushUserContext($url); - CRM_Core_Error::statusBounce(ts("You do not have any active Case Types")); - } - // check if activity count is within the limit $xmlProcessor = new CRM_Case_XMLProcessor_Process(); foreach ($this->_caseId as $casePos => $caseId) { diff --git a/CRM/Case/Form/Activity/ChangeCaseType.php b/CRM/Case/Form/Activity/ChangeCaseType.php index bf85169449..be93779292 100644 --- a/CRM/Case/Form/Activity/ChangeCaseType.php +++ b/CRM/Case/Form/Activity/ChangeCaseType.php @@ -68,7 +68,7 @@ class CRM_Case_Form_Activity_ChangeCaseType { $form->_caseType[$form->_caseTypeId] = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', $form->_caseTypeId, 'title'); } - $form->addField('case_type_id', ['context' => 'create', 'entity' => 'Case']); + $form->addField('case_type_id', ['context' => 'create', 'entity' => 'Case'], TRUE); // timeline $form->addYesNo('is_reset_timeline', ts('Reset Case Timeline?'), NULL, TRUE); diff --git a/tests/phpunit/CRM/Core/FormTest.php b/tests/phpunit/CRM/Core/FormTest.php index fd7d695fb4..c55826cee5 100644 --- a/tests/phpunit/CRM/Core/FormTest.php +++ b/tests/phpunit/CRM/Core/FormTest.php @@ -57,6 +57,14 @@ class CRM_Core_FormTest extends CiviUnitTestCase { $form->_action = CRM_Core_Action::ADD; }, ], + // This one is a bit flawed but the only point of this test is to catch + // simple stuff. This will catch e.g. "undefined index" and similar. + 'Find Contacts' => [ + 'CRM_Contact_Form_Search_Basic', + function(CRM_Core_Form $form) { + $form->_action = CRM_Core_Action::BASIC; + }, + ], ]; } -- 2.25.1