function OptionsFieldUnitTestBase::setUp

Same name in other branches
  1. 9 core/modules/options/tests/src/Kernel/OptionsFieldUnitTestBase.php \Drupal\Tests\options\Kernel\OptionsFieldUnitTestBase::setUp()
  2. 8.9.x core/modules/options/tests/src/Kernel/OptionsFieldUnitTestBase.php \Drupal\Tests\options\Kernel\OptionsFieldUnitTestBase::setUp()
  3. 11.x core/modules/options/tests/src/Kernel/OptionsFieldUnitTestBase.php \Drupal\Tests\options\Kernel\OptionsFieldUnitTestBase::setUp()

Overrides FieldKernelTestBase::setUp

3 calls to OptionsFieldUnitTestBase::setUp()
OptionsDynamicValuesApiTest::setUp in core/modules/options/tests/src/Kernel/OptionsDynamicValuesApiTest.php
Set the default field storage backend for fields created during tests.
OptionsDynamicValuesValidationTest::setUp in core/modules/options/tests/src/Kernel/OptionsDynamicValuesValidationTest.php
Set the default field storage backend for fields created during tests.
OptionsFormattersTest::setUp in core/modules/options/tests/src/Kernel/OptionsFormattersTest.php
Set the default field storage backend for fields created during tests.
3 methods override OptionsFieldUnitTestBase::setUp()
OptionsDynamicValuesApiTest::setUp in core/modules/options/tests/src/Kernel/OptionsDynamicValuesApiTest.php
Set the default field storage backend for fields created during tests.
OptionsDynamicValuesValidationTest::setUp in core/modules/options/tests/src/Kernel/OptionsDynamicValuesValidationTest.php
Set the default field storage backend for fields created during tests.
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() : 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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.