protected function RangeBrowserTestBase::createRangeField 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.
1 call to RangeBrowserTestBase::createRangeField()
- RangeFieldValidationTest::testRangeValidation in tests/
src/ Functional/ RangeFieldValidationTest.php - Tests range field validation.
File
- tests/
src/ Functional/ RangeBrowserTestBase.php, line 137
Class
- RangeBrowserTestBase
- Base class for the range module's tests.
Namespace
Drupal\Tests\range\FunctionalCode
protected function createRangeField($field_type = 'range_integer') {
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $this
->getTestFieldName($field_type),
'entity_type' => $this->entityTypeId,
'type' => $field_type,
'settings' => $this
->getTestFieldStorageSettings($field_type),
]);
$this->fieldStorage
->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => $this->bundle,
'settings' => $this
->getTestFieldSettings($field_type),
]);
$this->field
->save();
\Drupal::service('entity_display.repository')
->getFormDisplay($this->entityTypeId, $this->bundle, 'default')
->setComponent($this
->getTestFieldName($field_type), [
'type' => 'range',
])
->save();
}