protected function OptionsFieldUnitTestBase::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/modules/options/tests/src/Kernel/OptionsFieldUnitTestBase.php \Drupal\Tests\options\Kernel\OptionsFieldUnitTestBase::setUp()
- 9 core/modules/options/tests/src/Kernel/OptionsFieldUnitTestBase.php \Drupal\Tests\options\Kernel\OptionsFieldUnitTestBase::setUp()
File
- core/
modules/ options/ tests/ src/ Kernel/ OptionsFieldUnitTestBase.php, line 52
Class
- OptionsFieldUnitTestBase
- Base class for Options module integration tests.
Namespace
Drupal\Tests\options\KernelCode
protected function setUp() : void {
parent::setUp();
$this->fieldStorageDefinition = [
'field_name' => $this->fieldName,
'entity_type' => 'entity_test',
'type' => 'list_integer',
'cardinality' => 1,
'settings' => [
'allowed_values' => [
1 => 'One',
2 => 'Two',
3 => 'Three',
],
],
];
$this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
$this->fieldStorage
->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
]);
$this->field
->save();
\Drupal::service('entity_display.repository')
->getFormDisplay('entity_test', 'entity_test')
->setComponent($this->fieldName, [
'type' => 'options_buttons',
])
->save();
}