3 namespace Drupal\Tests\options\Kernel;
5 use Drupal\field\Entity\FieldConfig;
6 use Drupal\Tests\field\Kernel\FieldKernelTestBase;
7 use Drupal\field\Entity\FieldStorageConfig;
10 * Base class for Options module integration tests.
12 abstract class OptionsFieldUnitTestBase extends FieldKernelTestBase {
19 public static $modules = ['options'];
22 * The field name used in the test.
26 protected $fieldName = 'test_options';
29 * The field storage definition used to created the field storage.
33 protected $fieldStorageDefinition;
36 * The list field storage used in the test.
38 * @var \Drupal\field\Entity\FieldStorageConfig
40 protected $fieldStorage;
43 * The list field used in the test.
45 * @var \Drupal\field\Entity\FieldConfig
52 protected function setUp() {
54 $this->container->get('router.builder')->rebuild();
56 $this->fieldStorageDefinition = [
57 'field_name' => $this->fieldName,
58 'entity_type' => 'entity_test',
59 'type' => 'list_integer',
62 'allowed_values' => [1 => 'One', 2 => 'Two', 3 => 'Three'],
65 $this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
66 $this->fieldStorage->save();
68 $this->field = FieldConfig::create([
69 'field_storage' => $this->fieldStorage,
70 'bundle' => 'entity_test',
74 entity_get_form_display('entity_test', 'entity_test', 'default')
75 ->setComponent($this->fieldName, [
76 'type' => 'options_buttons',