function FilterDateTimeTest::_testOffset
Same name and namespace in other branches
- 9 core/modules/datetime/tests/src/Kernel/Views/FilterDateTimeTest.php \Drupal\Tests\datetime\Kernel\Views\FilterDateTimeTest::_testOffset()
- 8.9.x core/modules/datetime/tests/src/Kernel/Views/FilterDateTimeTest.php \Drupal\Tests\datetime\Kernel\Views\FilterDateTimeTest::_testOffset()
- 10 core/modules/datetime/tests/src/Kernel/Views/FilterDateTimeTest.php \Drupal\Tests\datetime\Kernel\Views\FilterDateTimeTest::_testOffset()
Tests offset operations.
1 call to FilterDateTimeTest::_testOffset()
- 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 85
Class
- FilterDateTimeTest
- 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\ViewsCode
protected function _testOffset() {
$view = Views::getView('test_filter_datetime');
$field = static::$fieldName . '_value';
// Test simple operations.
$view->initHandlers();
$view->filter[$field]->operator = '>';
$view->filter[$field]->value['type'] = 'offset';
$view->filter[$field]->value['value'] = '+1 hour';
$view->setDisplay('default');
$this->executeView($view);
$expected_result = [
[
'nid' => $this->nodes[3]
->id(),
],
];
$this->assertIdenticalResultset($view, $expected_result, $this->map);
$view->destroy();
// Test offset for between operator.
$view->initHandlers();
$view->filter[$field]->operator = 'between';
$view->filter[$field]->value['type'] = 'offset';
$view->filter[$field]->value['max'] = '+2 days';
$view->filter[$field]->value['min'] = '+1 hour';
$view->setDisplay('default');
$this->executeView($view);
$expected_result = [
[
'nid' => $this->nodes[3]
->id(),
],
];
$this->assertIdenticalResultset($view, $expected_result, $this->map);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.