You are here

public function FilterDateTimeTest::setUp in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php \Drupal\datetime\Tests\Views\FilterDateTimeTest::setUp()

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides DateTimeHandlerTestBase::setUp

File

core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php, line 37
Contains \Drupal\datetime\Tests\Views\FilterDateTimeTest.

Class

FilterDateTimeTest
Tests the Drupal\datetime\Plugin\views\filter\Date handler.

Namespace

Drupal\datetime\Tests\Views

Code

public function setUp() {
  parent::setUp();
  static::$date = REQUEST_TIME + 86400;

  // Set the timezone.
  date_default_timezone_set(static::$timezone);

  // Add some basic test nodes.
  $dates = [
    '2000-10-10T00:01:30',
    '2001-10-10T12:12:12',
    '2002-10-10T14:14:14',
    // The date storage timezone is used (this mimics the steps taken in the
    // widget: \Drupal\datetime\Plugin\Field\FieldWidget::messageFormValues().
    \Drupal::service('date.formatter')
      ->format(static::$date, 'custom', DATETIME_DATETIME_STORAGE_FORMAT, DATETIME_STORAGE_TIMEZONE),
  ];
  foreach ($dates as $date) {
    $this->nodes[] = $this
      ->drupalCreateNode([
      'field_date' => [
        'value' => $date,
      ],
    ]);
  }
}