Skip to content

Commit

Permalink
APIv4 - Create necessary fk entities in conformance test
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Feb 18, 2022
1 parent 7e5ada4 commit 5e4086a
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,12 @@ private function getFkID(string $fkEntity) {
$params['where'] = [['contact_type', '=', 'Individual']];
}
$entityList = civicrm_api4($fkEntity, 'get', $params);
// If no existing entities, create one
if ($entityList->count() < 1) {
$msg = sprintf('At least one %s is required in test', $fkEntity);
throw new \API_Exception($msg);
$entityList = civicrm_api4($fkEntity, 'create', [
'checkPermissions' => FALSE,
'values' => $this->getRequired($fkEntity),
]);
}

return $entityList->last()['id'];
Expand Down

0 comments on commit 5e4086a

Please sign in to comment.