From 1b9b056c5ac9936325eaecc54a648fc5e0ea3814 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 17 Feb 2022 20:45:37 -0500 Subject: [PATCH] APIv4 - Create necessary fk entities in conformance test --- .../api/v4/Service/TestCreationParameterProvider.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/api/v4/Service/TestCreationParameterProvider.php b/tests/phpunit/api/v4/Service/TestCreationParameterProvider.php index 5bdc2ce7ce..4db5a44423 100644 --- a/tests/phpunit/api/v4/Service/TestCreationParameterProvider.php +++ b/tests/phpunit/api/v4/Service/TestCreationParameterProvider.php @@ -150,9 +150,12 @@ class TestCreationParameterProvider { $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']; -- 2.25.1