function FilterDateTimeTest::_testExact

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

Tests exact date matching.

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

File

core/modules/datetime/tests/src/Kernel/Views/FilterDateTimeTest.php, line 185

Class

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

Namespace

Drupal\Tests\datetime\Kernel\Views

Code

protected function _testExact() : void {
  $view = Views::getView('test_filter_datetime');
  $field = static::$fieldName . '_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', DateTimeItemInterface::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();
}

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