You are here

protected function FilterDateTimeTest::_testExact 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::_testExact()

Test exact date matching.

1 call to FilterDateTimeTest::_testExact()
FilterDateTimeTest::testDatetimeFilter in core/modules/datetime/src/Tests/Views/FilterDateTimeTest.php
Test filter operations.

File

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

Class

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

Namespace

Drupal\datetime\Tests\Views

Code

protected function _testExact() {
  $view = Views::getView('test_filter_datetime');
  $field = static::$field_name . '_value';

  // Test between with min and max.
  $view
    ->initHandlers();
  $view->filter[$field]->operator = '=';
  $view->filter[$field]->value['min'] = '';
  $view->filter[$field]->value['max'] = '';

  // Use the date from node 3. Use the site timezone (mimics a value entered
  // through the UI).
  $view->filter[$field]->value['value'] = \Drupal::service('date.formatter')
    ->format(static::$date, 'custom', DATETIME_DATETIME_STORAGE_FORMAT, static::$timezone);
  $view
    ->setDisplay('default');
  $this
    ->executeView($view);
  $expected_result = [
    [
      'nid' => $this->nodes[3]
        ->id(),
    ],
  ];
  $this
    ->assertIdenticalResultset($view, $expected_result, $this->map);
  $view
    ->destroy();
}