protected function RecipeTotalTimeConfigTest::createIntegerField in Recipe 8.2
Creates a new integer field.
Parameters
string $name: The name of the new field (all lowercase), exclude the "field_" prefix.
string $entity_type: The entity type.
string $bundle: The bundle that this field will be added to.
array $storage_settings: A list of field storage settings that will be added to the defaults.
array $field_settings: A list of instance settings that will be added to the instance defaults.
array $widget_settings: A list of widget settings that will be added to the widget defaults.
array $display_settings: A list of display settings that will be added to the display defaults.
1 call to RecipeTotalTimeConfigTest::createIntegerField()
- RecipeTotalTimeConfigTest::testIntegerFieldTotalTimeConfig in tests/
src/ Functional/ RecipeTotalTimeConfigTest.php - Tests the integer field third-party settings.
File
- tests/
src/ Functional/ RecipeTotalTimeConfigTest.php, line 130
Class
- RecipeTotalTimeConfigTest
- Tests the functionality of the Recipe Total Time third-party settings.
Namespace
Drupal\Tests\recipe\FunctionalCode
protected function createIntegerField($name, $entity_type, $bundle, array $storage_settings = [], array $field_settings = [], array $widget_settings = [], array $display_settings = []) {
$field_storage = $this->entityTypeManager
->getStorage('field_storage_config')
->create([
'entity_type' => $entity_type,
'field_name' => $name,
'type' => 'integer',
'settings' => $storage_settings,
'cardinality' => !empty($storage_settings['cardinality']) ? $storage_settings['cardinality'] : 1,
]);
$field_storage
->save();
$this
->attachIntegerField($name, $entity_type, $bundle, $field_settings, $widget_settings, $display_settings);
return $field_storage;
}