function SortDateTimeTest::setUp

Same name and namespace in other branches
  1. 9 core/modules/datetime/tests/src/Kernel/Views/SortDateTimeTest.php \Drupal\Tests\datetime\Kernel\Views\SortDateTimeTest::setUp()
  2. 8.9.x core/modules/datetime/tests/src/Kernel/Views/SortDateTimeTest.php \Drupal\Tests\datetime\Kernel\Views\SortDateTimeTest::setUp()
  3. 10 core/modules/datetime/tests/src/Kernel/Views/SortDateTimeTest.php \Drupal\Tests\datetime\Kernel\Views\SortDateTimeTest::setUp()

Overrides DateTimeHandlerTestBase::setUp

File

core/modules/datetime/tests/src/Kernel/Views/SortDateTimeTest.php, line 25

Class

SortDateTimeTest
Tests for core <a href="/api/drupal/core%21modules%21datetime%21src%21Plugin%21views%21sort%21Date.php/class/Date/11.x" title="Basic sort handler for datetime fields." class="local">Drupal\datetime\Plugin\views\sort\Date</a> handler.

Namespace

Drupal\Tests\datetime\Kernel\Views

Code

protected function setUp($import_test_views = TRUE) : void {
    parent::setUp($import_test_views);
    // Add some basic test nodes.
    $dates = [
        '2014-10-10T00:03:00',
        '2000-10-10T00:01:00',
        '2000-10-10T00:02:00',
        '2000-10-10T00:03:00',
        '2000-10-10T00:03:02',
        '2000-10-10T00:03:01',
        '2000-10-10T00:03:03',
    ];
    foreach ($dates as $date) {
        $node = Node::create([
            'title' => $this->randomMachineName(8),
            'type' => 'page',
            'field_date' => [
                'value' => $date,
            ],
        ]);
        $node->save();
        $this->nodes[] = $node;
    }
}

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