You are here

protected function RangeTestTrait::createField in Range 8

Creates a range field of a given type.

Parameters

string $field_type: Range field type. Could be one of the following values: range_integer, range_float or range_decimal.

4 calls to RangeTestTrait::createField()
FormatterTestBase::setUp in tests/src/Kernel/Formatter/FormatterTestBase.php
RangeFormatterUiTestBase::setUp in tests/src/Functional/Formatter/RangeFormatterUiTestBase.php
RangeWidgetUiTest::testTextFieldsWidgetUi in tests/src/Functional/Widget/RangeWidgetUiTest.php
Tests widget UI.
WidgetTest::testFieldWidget in tests/src/Kernel/Widget/WidgetTest.php
Tests widget.

File

tests/src/Traits/RangeTestTrait.php, line 171

Class

RangeTestTrait
Provides helper methods to test range fields.

Namespace

Drupal\Tests\range\Traits

Code

protected function createField($field_type = 'range_integer') {
  $this->fieldStorage = FieldStorageConfig::create([
    'field_name' => $this
      ->getFieldName($field_type),
    'entity_type' => $this->entityType,
    'type' => $field_type,
    'settings' => $this
      ->getFieldStorageSettings($field_type),
  ]);
  $this->fieldStorage
    ->save();
  $this->field = FieldConfig::create([
    'field_storage' => $this->fieldStorage,
    'bundle' => $this->bundle,
    'settings' => $this
      ->getFieldSettings($field_type),
  ]);
  $this->field
    ->save();
}