protected function QuickEditTestBase::createFieldWithStorage in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/quickedit/src/Tests/QuickEditTestBase.php \Drupal\quickedit\Tests\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/ src/ Tests/ EditorSelectionTest.php - Tests a number field, with cardinality 1 and >1.
- EditorSelectionTest::testText in core/
modules/ quickedit/ src/ Tests/ EditorSelectionTest.php - Tests a string (plain text) field, with cardinality 1 and >1.
- EditorSelectionTest::testTextWysiwyg in core/
modules/ quickedit/ src/ Tests/ 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/ src/ Tests/ MetadataGeneratorTest.php - Tests a field whose associated in-place editor generates custom metadata.
- MetadataGeneratorTest::testSimpleEntityType in core/
modules/ quickedit/ src/ Tests/ MetadataGeneratorTest.php - Tests a simple entity type, with two different simple fields.
File
- core/
modules/ quickedit/ src/ Tests/ QuickEditTestBase.php, line 71 - Contains \Drupal\quickedit\Tests\QuickEditTestBase.
Class
- QuickEditTestBase
- Base class for testing Quick Edit functionality.
Namespace
Drupal\quickedit\TestsCode
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} = entity_create('field_storage_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => $type,
'cardinality' => $cardinality,
));
$this->fields->{$field_storage}
->save();
$field = $field_name . '_field';
$this->fields->{$field} = entity_create('field_config', array(
'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();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
'type' => $widget_type,
'settings' => $widget_settings,
))
->save();
entity_get_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
'label' => 'above',
'type' => $formatter_type,
'settings' => $formatter_settings,
))
->save();
}