You are here

public function ContributionPayLaterTest::createFinancialCustomGroup in Webform CiviCRM Integration 8.5

Create custom sets for financial type.

Parameters

string $ftName:

1 call to ContributionPayLaterTest::createFinancialCustomGroup()
ContributionPayLaterTest::testSubmitContribution in tests/src/FunctionalJavascript/ContributionPayLaterTest.php

File

tests/src/FunctionalJavascript/ContributionPayLaterTest.php, line 112

Class

ContributionPayLaterTest
Tests submitting a Webform with CiviCRM: Contribution with Pay later

Namespace

Drupal\Tests\webform_civicrm\FunctionalJavascript

Code

public function createFinancialCustomGroup($ftName = NULL) {
  $params = [
    'title' => "{$ftName} Custom Group",
    'extends' => "Contribution",
  ];
  if ($ftName) {
    $ftId = civicrm_api3('FinancialType', 'get', [
      'return' => [
        "id",
      ],
      'name' => $ftName,
    ])['id'];
    $params['extends_entity_column_value'] = $ftId;
  }
  $key = $ftName ?? 'all';
  $this->_customGroup[$key] = reset($this
    ->createCustomGroup($params)['values']);

  // Add custom field.
  $params = [
    'custom_group_id' => $this->_customGroup[$key]['id'],
    'label' => "{$ftName} Custom Field",
    'data_type' => 'String',
    'html_type' => 'Text',
  ];
  $cf = $this->utils
    ->wf_civicrm_api('CustomField', 'create', $params);
  $this
    ->assertEquals(0, $cf['is_error']);
  $this
    ->assertEquals(1, $cf['count']);
  $this->_customFields[$key] = reset($cf['values']);
}