You are here

protected function OptionsFieldUnitTestBase::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/options/tests/src/Kernel/OptionsFieldUnitTestBase.php \Drupal\Tests\options\Kernel\OptionsFieldUnitTestBase::setUp()

Set the default field storage backend for fields created during tests.

Overrides FieldKernelTestBase::setUp

1 call to OptionsFieldUnitTestBase::setUp()
OptionsFormattersTest::setUp in core/modules/options/tests/src/Kernel/OptionsFormattersTest.php
Set the default field storage backend for fields created during tests.
1 method overrides OptionsFieldUnitTestBase::setUp()
OptionsFormattersTest::setUp in core/modules/options/tests/src/Kernel/OptionsFormattersTest.php
Set the default field storage backend for fields created during tests.

File

core/modules/options/tests/src/Kernel/OptionsFieldUnitTestBase.php, line 52

Class

OptionsFieldUnitTestBase
Base class for Options module integration tests.

Namespace

Drupal\Tests\options\Kernel

Code

protected function setUp() {
  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();
}