You are here

private function FieldGroupLinkDisplayTest::setupFields in Field Group Link 8.3

Add fields to our content type.

1 call to FieldGroupLinkDisplayTest::setupFields()
FieldGroupLinkDisplayTest::setUp in tests/src/Functional/FieldGroupLinkDisplayTest.php

File

tests/src/Functional/FieldGroupLinkDisplayTest.php, line 126

Class

FieldGroupLinkDisplayTest
Tests for displaying entities.

Namespace

Drupal\Tests\field_group_link\Functional

Code

private function setupFields() {
  $fields = [
    [
      'field_name' => 'field_test',
      'type' => 'test_field',
    ],
    [
      'field_name' => 'field_test_entity_reference',
      'type' => 'entity_reference',
      'settings' => [
        'target_type' => 'node',
      ],
    ],
    [
      'field_name' => 'field_test_link',
      'type' => 'link',
    ],
  ];
  foreach ($fields as $field_config) {
    $field_config_default = [
      'entity_type' => 'node',
      'translatable' => FALSE,
      'cardinality' => 1,
    ];
    $field_storage = FieldStorageConfig::create($field_config + $field_config_default);
    $field_storage
      ->save();
    $instance = FieldConfig::create([
      'field_storage' => $field_storage,
      'bundle' => $this->type,
      'label' => $this
        ->randomMachineName(),
    ]);
    $instance
      ->save();
  }
}