Skip to content

Commit

Permalink
Start using apiv4 in test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton authored and colemanw committed Apr 8, 2020
1 parent 7784539 commit cf66fb2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/phpunit/CRMTraits/Custom/CustomDataTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
+--------------------------------------------------------------------+
*/

use Civi\Api4\CustomGroup;

/**
* Trait Custom Data trait.
*
Expand All @@ -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);
Expand All @@ -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([
Expand All @@ -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];
}

Expand Down Expand Up @@ -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'];
Expand Down

0 comments on commit cf66fb2

Please sign in to comment.