You are here

protected function SortDateTimeTest::setUp in Drupal 8

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. 10 core/modules/datetime/tests/src/Kernel/Views/SortDateTimeTest.php \Drupal\Tests\datetime\Kernel\Views\SortDateTimeTest::setUp()

Parameters

bool $import_test_views: Should the views specified on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.

Overrides DateTimeHandlerTestBase::setUp

File

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

Class

SortDateTimeTest
Tests for core Drupal\datetime\Plugin\views\sort\Date handler.

Namespace

Drupal\Tests\datetime\Kernel\Views

Code

protected function setUp($import_test_views = TRUE) {
  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;
  }
}