From 0ca4b2094905053ea30b5d852491e93e1d7533e3 Mon Sep 17 00:00:00 2001 From: DemeritCowboy Date: Thu, 14 Nov 2019 22:45:00 -0500 Subject: [PATCH] Avoid duplicate activity types --- tests/phpunit/CiviTest/CiviCaseTestCase.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviCaseTestCase.php b/tests/phpunit/CiviTest/CiviCaseTestCase.php index e49789d59b..373274a0c3 100644 --- a/tests/phpunit/CiviTest/CiviCaseTestCase.php +++ b/tests/phpunit/CiviTest/CiviCaseTestCase.php @@ -38,22 +38,23 @@ class CiviCaseTestCase extends CiviUnitTestCase { 'name' => 'case_status', 'format.only_id' => 1, )); - $optionValues = array( + $optionValues = [ 'Medical evaluation' => 'Medical evaluation', 'Mental health evaluation' => "Mental health evaluation", 'Secure temporary housing' => 'Secure temporary housing', 'Long-term housing plan' => 'Long-term housing plan', 'ADC referral' => 'ADC referral', 'Income and benefits stabilization' => 'Income and benefits stabilization', - ); + ]; foreach ($optionValues as $name => $label) { - $activityTypes = $this->callAPISuccess('option_value', 'Create', array( - 'option_group_id' => 2, + $activityTypes = CRM_Core_BAO_OptionValue::ensureOptionValueExists([ + 'option_group_id' => 'activity_type', 'name' => $name, 'label' => $label, - 'component_id' => 7, - )); + 'component_id' => 'CiviCase', + ]); // store for cleanup + // @todo is this ever used? $this->optionValues[] = $activityTypes['id']; } -- 2.25.1