From 1be6caec5a354c52bda03aee309f5f3aa0412167 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sun, 13 Jul 2014 19:36:21 -0700 Subject: [PATCH] api_v3_CaseTest - Fix failures. Load case-types by name (not title). The old title-based lookup worked because it was subjected to munging, but that mechanism changed in CRM-14798. --- Civi/CCase/Events.php | 6 +++++- api/v3/Case.php | 2 +- tests/phpunit/api/v3/CaseTest.php | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Civi/CCase/Events.php b/Civi/CCase/Events.php index 472ac9f647..5ff4060046 100644 --- a/Civi/CCase/Events.php +++ b/Civi/CCase/Events.php @@ -49,7 +49,11 @@ class Events { } break; case 'Case': - $caseId = $event->id; + // by the time we get the post-delete event, the record is gone, so + // there's nothing to analyze + if ($event->action != 'delete') { + $caseId = $event->id; + } break; default: throw new \CRM_Core_Exception("CRM_Case_Listener does not support entity {$event->entity}"); diff --git a/api/v3/Case.php b/api/v3/Case.php index 7a6bf6c61d..ccbe0370cc 100644 --- a/api/v3/Case.php +++ b/api/v3/Case.php @@ -417,7 +417,7 @@ function _civicrm_api3_case_read($caseId, $options) { */ function _civicrm_api3_case_format_params(&$params) { // figure out case type id from case type and vice-versa - $caseTypes = CRM_Case_PseudoConstant::caseType('title', FALSE); + $caseTypes = CRM_Case_PseudoConstant::caseType('name', FALSE); if (empty($params['case_type_id'])) { $params['case_type_id'] = array_search($params['case_type'], $caseTypes); } diff --git a/tests/phpunit/api/v3/CaseTest.php b/tests/phpunit/api/v3/CaseTest.php index 19935366e2..4d9c6b0035 100644 --- a/tests/phpunit/api/v3/CaseTest.php +++ b/tests/phpunit/api/v3/CaseTest.php @@ -97,7 +97,7 @@ class api_v3_CaseTest extends CiviCaseTestCase { $params = $this->_params; // Test using label instead of value unset($params['case_type_id']); - $params['case_type'] = 'Housing Support'; + $params['case_type'] = 'housing_support'; $result = $this->callAPISuccess('case', 'create', $params); $id = $result['id']; @@ -116,7 +116,7 @@ class api_v3_CaseTest extends CiviCaseTestCase { $params = $this->_params; // Test using name instead of value unset($params['case_type_id']); - $params['case_type'] = 'Housing Support'; + $params['case_type'] = 'housing_support'; $result = $this->callAPISuccess('case', 'create', $params); $id = $result['id']; $result = $this->callAPISuccess('case', 'get', array('id' => $id)); -- 2.25.1