You are here

protected function UiTest::addFieldsToEntities in Apigee Edge 8

Create custom fields for team and team app.

1 call to UiTest::addFieldsToEntities()
UiTest::setUp in modules/apigee_edge_teams/tests/src/Functional/UiTest.php

File

modules/apigee_edge_teams/tests/src/Functional/UiTest.php, line 321

Class

UiTest
Team and team app entity UI tests.

Namespace

Drupal\Tests\apigee_edge_teams\Functional

Code

protected function addFieldsToEntities() {
  $this
    ->drupalLogin($this->rootUser);
  $this->fields = [
    'integer' => [
      'type' => 'integer',
      'data' => rand(),
      'data_edited' => rand(),
    ],
    'email' => [
      'type' => 'email',
      'data' => $this
        ->randomMachineName() . '@example.com',
      'data_edited' => $this
        ->randomMachineName() . '@example.com',
    ],
  ];

  // Add fields to team and team app.
  $add_field_paths = [
    Url::fromRoute('apigee_edge_teams.settings.team')
      ->toString(),
    Url::fromRoute('apigee_edge_teams.settings.team_app')
      ->toString(),
  ];
  foreach ($add_field_paths as $add_field_path) {
    foreach ($this->fields as $name => $data) {
      $this
        ->fieldUIAddNewField($add_field_path, $name, mb_strtoupper($name), $data['type'], ($data['settings'] ?? []) + [
        'cardinality' => -1,
      ], []);
    }
  }
}