make case type required for change case type activity instead of a preprocess check...
authordemeritcowboy <demeritcowboy@hotmail.com>
Sun, 15 Mar 2020 22:57:24 +0000 (18:57 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Mon, 16 Mar 2020 04:40:14 +0000 (00:40 -0400)
CRM/Case/Form/Activity.php
CRM/Case/Form/Activity/ChangeCaseType.php
tests/phpunit/CRM/Core/FormTest.php

index 219fa7dc057d24f32402953f08843b74eb9cf979..2b3f1ee862edab15a2caab087addcb6f64e7031f 100644 (file)
@@ -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) {
index bf85169449e81548613aaa849b57c86e64de5bd4..be93779292fdb13149f9415be4b629c869df30bb 100644 (file)
@@ -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);
index fd7d695fb4733dc3072ed19562c0e45919653a24..c55826cee59865938f23b93517bee87bd6cfbab1 100644 (file)
@@ -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;
+        },
+      ],
     ];
   }