function DateFilterTest::setUp

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

Overrides ViewTestBase::setUp

File

core/modules/datetime/tests/src/Functional/DateFilterTest.php, line 54

Class

DateFilterTest
Test exposed datetime filters functionality.

Namespace

Drupal\Tests\datetime\Functional

Code

protected function setUp($import_test_views = TRUE, $modules = [
    'datetime_test',
]) : void {
    parent::setUp($import_test_views, $modules);
    // Add a date field to page nodes.
    $node_type = NodeType::create([
        'type' => 'page',
        'name' => 'page',
    ]);
    $node_type->save();
    $fieldStorage = FieldStorageConfig::create([
        'field_name' => 'field_date',
        'entity_type' => 'node',
        'type' => 'datetime',
        'settings' => [
            'datetime_type' => DateTimeItem::DATETIME_TYPE_DATETIME,
        ],
    ]);
    $fieldStorage->save();
    $field = FieldConfig::create([
        'field_storage' => $fieldStorage,
        'bundle' => 'page',
        'required' => TRUE,
    ]);
    $field->save();
    $this->adminUser = $this->drupalCreateUser([
        'administer views',
    ]);
    $this->drupalLogin($this->adminUser);
    $this->drupalCreateContentType([
        'type' => 'article',
        'name' => 'Article',
    ]);
}

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