You are here

protected function AutofillJavascriptTest::setupFields in Autofill 8

Creates the necessary fields.

Throws

\Drupal\Core\Entity\EntityStorageException

1 call to AutofillJavascriptTest::setupFields()
AutofillJavascriptTest::setUp in tests/src/FunctionalJavascript/AutofillJavascriptTest.php

File

tests/src/FunctionalJavascript/AutofillJavascriptTest.php, line 94

Class

AutofillJavascriptTest
Tests the Autofill module.

Namespace

Drupal\Tests\autofill\FunctionalJavascript

Code

protected function setupFields() {

  // Set up two source fields and one target.
  $fields = [
    'field_source_1',
    'field_target_1',
    'field_source_2',
    'field_target_2',
  ];
  foreach ($fields as $field) {
    FieldStorageConfig::create([
      'field_name' => $field,
      'entity_type' => 'node',
      'type' => 'string',
      'cardinality' => 1,
    ])
      ->save();
    FieldConfig::create([
      'entity_type' => 'node',
      'field_name' => $field,
      'bundle' => $this->contentType
        ->id(),
      'label' => $field,
    ])
      ->save();
    EntityFormDisplay::load('node.article.default')
      ->setComponent($field)
      ->save();
  }
}