function TextWithSummaryItemTest::createField

Same name in other branches
  1. 8.9.x core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php \Drupal\Tests\text\Kernel\TextWithSummaryItemTest::createField()
  2. 10 core/modules/text/tests/src/Kernel/TextWithSummaryItemTest.php \Drupal\Tests\text\Kernel\TextWithSummaryItemTest::createField()
  3. 11.x 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 104

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.