protected function QuickEditTestBase::createFieldWithStorage in Drupal 8
Same name and namespace in other branches
- 9 core/modules/quickedit/tests/src/Kernel/QuickEditTestBase.php \Drupal\Tests\quickedit\Kernel\QuickEditTestBase::createFieldWithStorage()
- 10 core/modules/quickedit/tests/src/Kernel/QuickEditTestBase.php \Drupal\Tests\quickedit\Kernel\QuickEditTestBase::createFieldWithStorage()
Creates a field.
Parameters
string $field_name: The field name.
string $type: The field type.
int $cardinality: The field's cardinality.
string $label: The field's label (used everywhere: widget label, formatter label).
array $field_settings:
string $widget_type: The widget type.
array $widget_settings: The widget settings.
string $formatter_type: The formatter type.
array $formatter_settings: The formatter settings.
6 calls to QuickEditTestBase::createFieldWithStorage()
- EditorSelectionTest::testNumber in core/
modules/ quickedit/ tests/ src/ Kernel/ EditorSelectionTest.php - Tests a number field, with cardinality 1 and >1.
- EditorSelectionTest::testText in core/
modules/ quickedit/ tests/ src/ Kernel/ EditorSelectionTest.php - Tests a string (plain text) field, with cardinality 1 and >1.
- EditorSelectionTest::testTextWysiwyg in core/
modules/ quickedit/ tests/ src/ Kernel/ EditorSelectionTest.php - Tests a textual field, with text filtering, with cardinality 1 and >1, always with an Editor plugin present that supports textual fields with text filtering, but with varying text format compatibility.
- MetadataGeneratorTest::testEditorWithCustomMetadata in core/
modules/ quickedit/ tests/ src/ Kernel/ MetadataGeneratorTest.php - Tests a field whose associated in-place editor generates custom metadata.
- MetadataGeneratorTest::testSimpleEntityType in core/
modules/ quickedit/ tests/ src/ Kernel/ MetadataGeneratorTest.php - Tests a simple entity type, with two different simple fields.
File
- core/
modules/ quickedit/ tests/ src/ Kernel/ QuickEditTestBase.php, line 77
Class
- QuickEditTestBase
- Base class for testing Quick Edit functionality.
Namespace
Drupal\Tests\quickedit\KernelCode
protected function createFieldWithStorage($field_name, $type, $cardinality, $label, $field_settings, $widget_type, $widget_settings, $formatter_type, $formatter_settings) {
$field_storage = $field_name . '_field_storage';
$this->fields->{$field_storage} = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => $type,
'cardinality' => $cardinality,
]);
$this->fields->{$field_storage}
->save();
$field = $field_name . '_field';
$this->fields->{$field} = FieldConfig::create([
'field_storage' => $this->fields->{$field_storage},
'bundle' => 'entity_test',
'label' => $label,
'description' => $label,
'weight' => mt_rand(0, 127),
'settings' => $field_settings,
]);
$this->fields->{$field}
->save();
/** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
$display_repository = \Drupal::service('entity_display.repository');
$display_repository
->getFormDisplay('entity_test', 'entity_test')
->setComponent($field_name, [
'type' => $widget_type,
'settings' => $widget_settings,
])
->save();
$display_repository
->getViewDisplay('entity_test', 'entity_test')
->setComponent($field_name, [
'label' => 'above',
'type' => $formatter_type,
'settings' => $formatter_settings,
])
->save();
}