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. 10 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

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->container
        ->get('router.builder')
        ->rebuild();
    $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.