From 36ded879c53383ba03dd0ec4b6111d9a68915fb5 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 8 Apr 2020 14:35:45 +1200 Subject: [PATCH] Start using apiv4 in test setup --- tests/phpunit/CRMTraits/Custom/CustomDataTrait.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/CRMTraits/Custom/CustomDataTrait.php b/tests/phpunit/CRMTraits/Custom/CustomDataTrait.php index 6830c8a517dc..785d71372228 100644 --- a/tests/phpunit/CRMTraits/Custom/CustomDataTrait.php +++ b/tests/phpunit/CRMTraits/Custom/CustomDataTrait.php @@ -9,6 +9,7 @@ +--------------------------------------------------------------------+ */ +use Civi\Api4\CustomGroup; /** * Trait Custom Data trait. * @@ -20,6 +21,9 @@ trait CRMTraits_Custom_CustomDataTrait { * Create a custom group with fields of multiple types. * * @param array $groupParams + * + * @throws \API_Exception + * @throws \Civi\API\Exception\UnauthorizedException */ public function createCustomGroupWithFieldsOfAllTypes($groupParams = []) { $this->createCustomGroup($groupParams); @@ -32,6 +36,9 @@ public function createCustomGroupWithFieldsOfAllTypes($groupParams = []) { * @param array $params * * @return int + * + * @throws \API_Exception + * @throws \Civi\API\Exception\UnauthorizedException */ public function createCustomGroup($params = []) { $params = array_merge([ @@ -42,7 +49,7 @@ public function createCustomGroup($params = []) { 'max_multiple' => 0, ], $params); $identifier = $params['name'] ?? $params['title']; - $this->ids['CustomGroup'][$identifier] = $this->callAPISuccess('CustomGroup', 'create', $params)['id']; + $this->ids['CustomGroup'][$identifier] = CustomGroup::create()->setValues($params)->execute()->first()['id']; return $this->ids['CustomGroup'][$identifier]; } @@ -77,7 +84,9 @@ protected function getCustomFieldColumnName($key) { * * @param string $identifier * + * @throws \API_Exception * @throws \CRM_Core_Exception + * @throws \Civi\API\Exception\UnauthorizedException */ public function createCustomGroupWithFieldOfType($groupParams = [], $customFieldType = 'text', $identifier = NULL) { $supported = ['text', 'select', 'date', 'int'];