function ArgumentDateTimeTest::setUp

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

Overrides DateTimeHandlerTestBase::setUp

File

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

Class

ArgumentDateTimeTest
Tests the <a href="/api/drupal/core%21modules%21datetime%21src%21Plugin%21views%21filter%21Date.php/class/Date/11.x" title="Date/time views filter." class="local">Drupal\datetime\Plugin\views\filter\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 = [
        '2000-10-10',
        '2001-10-10',
        '2002-01-01',
        // Add a date that is the year 2002 in UTC, but 2003 in the site's time
        // zone (Australia/Sydney).
'2002-12-31T23:00:00',
    ];
    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.