From 913b5673db98df5c7aaceb4dc1e2d27c8ff13398 Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Mon, 4 Feb 2019 18:14:50 +0530 Subject: [PATCH] dev/core#684 - Case Manager not updating correctly --- CRM/Case/XMLProcessor/Process.php | 2 +- .../phpunit/CRM/Case/BAO/CaseTypeForkTest.php | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CRM/Case/XMLProcessor/Process.php b/CRM/Case/XMLProcessor/Process.php index eef735e44a..255c7cc029 100644 --- a/CRM/Case/XMLProcessor/Process.php +++ b/CRM/Case/XMLProcessor/Process.php @@ -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; } } diff --git a/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php b/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php index f91da9823d..21f0c46eb6 100644 --- a/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php +++ b/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php @@ -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. -- 2.25.1