function DateTimeItemTest::setUp

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

Overrides FieldKernelTestBase::setUp

File

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

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();
}

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