You are here

protected function TextWithSummaryItemTest::createField in Drupal 8

Same name and namespace in other branches
  1. 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.

1 call to TextWithSummaryItemTest::createField()
TextWithSummaryItemTest::testCrudAndUpdate in core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php
Tests processed properties.

File

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

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();
}