CiviCaseTestCase setup() can make duplicate activity type option values
See these lines https://github.com/civicrm/civicrm-core/blob/5.19.1/tests/phpunit/CiviTest/CiviCaseTestCase.php#L57-L71 and note that setup() also uses quickCleanup().
$optionValues = array(
'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,
'name' => $name,
'label' => $label,
'component_id' => 7,
));
So for example if you have a dataprovider that calls your test multiple times, it keeps creating new duplicate activity types with the same name
.
PR coming
In the option_value table definition maybe these keys should be unique keys, but that's extra.
KEY `index_option_group_id_value` (`value`(128),`option_group_id`),
KEY `index_option_group_id_name` (`name`(128),`option_group_id`),