From cf66fb209e3cdca29a68f6047f0294fb513e2407 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/CRMTraits/Custom/CustomDataTrait.php b/tests/phpunit/CRMTraits/Custom/CustomDataTrait.php index 6830c8a517dc..ebffde376b3d 100644 --- a/tests/phpunit/CRMTraits/Custom/CustomDataTrait.php +++ b/tests/phpunit/CRMTraits/Custom/CustomDataTrait.php @@ -9,6 +9,8 @@ +--------------------------------------------------------------------+ */ +use Civi\Api4\CustomGroup; + /** * Trait Custom Data trait. * @@ -20,6 +22,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 +37,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 +50,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()->setCheckPermissions(FALSE)->setValues($params)->execute()->first()['id']; return $this->ids['CustomGroup'][$identifier]; } @@ -77,7 +85,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'];