From c50e15c87a0b09f49c270171e9fe039c4f04fe84 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Mon, 2 Dec 2019 13:15:49 -0500 Subject: [PATCH] return manager info during api call --- CRM/Case/BAO/Case.php | 7 ++++--- tests/phpunit/api/v3/CaseTest.php | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index 00dbc265ed..99150f117c 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -1141,7 +1141,7 @@ SELECT civicrm_case.id, case_status.label AS case_status, status_id, civicrm_cas $values = []; $query = << $dao->phone, ]; // Add more info about the role (creator, manager) - $role = CRM_Utils_Array::value($dao->role_name, $caseRoles); + // The XML historically has the reverse direction, so look up reverse. + $role = CRM_Utils_Array::value($dao->role_name_reverse, $caseRoles); if ($role) { unset($role['name']); $details += $role; diff --git a/tests/phpunit/api/v3/CaseTest.php b/tests/phpunit/api/v3/CaseTest.php index f3baf27bc8..3e3e6fe379 100644 --- a/tests/phpunit/api/v3/CaseTest.php +++ b/tests/phpunit/api/v3/CaseTest.php @@ -651,15 +651,19 @@ class api_v3_CaseTest extends CiviCaseTestCase { 'status_id' => "Open", 'return' => ['contacts'], ]); + + $foundManager = FALSE; foreach ($result['contacts'] as $contact) { if ($contact['role'] == 'Client') { $this->assertEquals(17, $contact['contact_id']); } - elseif ($contact['role'] == 'Homeless Services Coordinator') { + elseif ($contact['role'] == 'Homeless Services Coordinator is') { $this->assertEquals(1, $contact['creator']); $this->assertEquals(1, $contact['manager']); + $foundManager = TRUE; } } + $this->assertTrue($foundManager); } public function testCaseGetWithDefinition() { -- 2.25.1