You are here

protected function ColorFieldTypeTest::setUp in Color Field 8.2

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

Overrides FieldKernelTestBase::setUp

File

tests/src/Kernel/ColorFieldTypeTest.php, line 29

Class

ColorFieldTypeTest
Tests the new entity API for the color field type.

Namespace

Drupal\Tests\color_field\Kernel

Code

protected function setUp() {
  parent::setUp();

  // Create a color field storage and field for validation.
  FieldStorageConfig::create([
    'field_name' => 'field_test',
    'entity_type' => 'entity_test',
    'type' => 'color_field_type',
  ])
    ->save();
  FieldConfig::create([
    'entity_type' => 'entity_test',
    'field_name' => 'field_test',
    'bundle' => 'entity_test',
  ])
    ->save();

  // Create a second field with different options.
  FieldStorageConfig::create([
    'field_name' => 'field_hex',
    'entity_type' => 'entity_test',
    'type' => 'color_field_type',
    'settings' => [
      'format' => 'hexhex',
    ],
  ])
    ->save();
  FieldConfig::create([
    'entity_type' => 'entity_test',
    'field_name' => 'field_hex',
    'bundle' => 'entity_test',
    'settings' => [
      'opacity' => FALSE,
    ],
  ])
    ->save();
}