dev/core#684 - Case Manager not updating correctly
authorJitendra Purohit <jitendra@fuzion.co.nz>
Mon, 4 Feb 2019 12:44:50 +0000 (18:14 +0530)
committerJitendra Purohit <jitendra@fuzion.co.nz>
Tue, 5 Feb 2019 11:18:03 +0000 (16:48 +0530)
CRM/Case/XMLProcessor/Process.php
tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php

index eef735e44a254611d66d52663b9a6810ae32171d..255c7cc02985470434a1e53117fd65d67270837d 100644 (file)
@@ -197,7 +197,7 @@ class CRM_Case_XMLProcessor_Process extends CRM_Case_XMLProcessor {
         if (!$isCaseManager) {
           $result[$relationshipTypeID] = $relationshipTypeName;
         }
-        elseif ($relationshipTypeXML->manager) {
+        elseif ($relationshipTypeXML->manager == 1) {
           return $relationshipTypeID;
         }
       }
index f91da9823df1e295c2c8f88f78808293d7799a15..21f0c46eb63952aa4812627f4b7fc5fde3cc38b3 100644 (file)
@@ -16,6 +16,31 @@ class CRM_Case_BAO_CaseTypeForkTest extends CiviCaseTestCase {
     CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
   }
 
+  /**
+   * Test Manager contact is correctly assigned via case type def.
+   */
+  public function testManagerContact() {
+    $caseTypeId = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', 'ForkableCaseType', 'id', 'name');
+    $this->assertTrue(is_numeric($caseTypeId) && $caseTypeId > 0);
+
+    $this->callAPISuccess('CaseType', 'create', [
+      'id' => $caseTypeId,
+      'definition' => [
+        'caseRoles' => [
+          ['name' => 'First role', 'manager' => 0],
+          ['name' => 'Second role', 'creator' => 1, 'manager' => 1],
+        ],
+      ],
+    ]);
+    $relTypeID = $this->callAPISuccessGetValue('RelationshipType', [
+      'return' => "id",
+      'name_b_a' => "Second role",
+    ]);
+    //Check if manager is correctly retrieved from xml processor.
+    $xmlProcessor = new CRM_Case_XMLProcessor_Process();
+    $this->assertEquals($relTypeID, $xmlProcessor->getCaseManagerRoleId('ForkableCaseType'));
+  }
+
 
   /**
    * Edit the definition of ForkableCaseType.