You are here

protected function TextWithSummaryItemTest::createField in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php \Drupal\Tests\text\Kernel\TextWithSummaryItemTest::createField()
  2. 9 core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php \Drupal\Tests\text\Kernel\TextWithSummaryItemTest::createField()

Creates a text_with_summary field storage and field.

Parameters

string $entity_type: Entity type for which the field should be created.

File

core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php, line 101

Class

TextWithSummaryItemTest
Tests using entity fields of the text summary field type.

Namespace

Drupal\Tests\text\Kernel

Code

protected function createField($entity_type) {

  // Create a field .
  $this->fieldStorage = FieldStorageConfig::create([
    'field_name' => 'summary_field',
    'entity_type' => $entity_type,
    'type' => 'text_with_summary',
    'settings' => [
      'max_length' => 10,
    ],
  ]);
  $this->fieldStorage
    ->save();
  $this->field = FieldConfig::create([
    'field_storage' => $this->fieldStorage,
    'bundle' => $entity_type,
  ]);
  $this->field
    ->save();
}