You are here

protected function DateTimeItemTest::setUp in Drupal 9

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

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

Overrides FieldKernelTestBase::setUp

File

core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php, line 43

Class

DateTimeItemTest
Tests the new entity API for the date field type.

Namespace

Drupal\Tests\datetime\Kernel

Code

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

  // Create a field with settings to validate.
  $this->fieldStorage = FieldStorageConfig::create([
    'field_name' => 'field_datetime',
    'type' => 'datetime',
    'entity_type' => 'entity_test',
    'settings' => [
      'datetime_type' => DateTimeItem::DATETIME_TYPE_DATETIME,
    ],
  ]);
  $this->fieldStorage
    ->save();
  $this->field = FieldConfig::create([
    'field_storage' => $this->fieldStorage,
    'bundle' => 'entity_test',
    'settings' => [
      'default_value' => 'blank',
    ],
  ]);
  $this->field
    ->save();
}