public function ArgumentDateTimeTest::testDatetimeArgumentYear in Drupal 10
Same name and namespace in other branches
- 8 core/modules/datetime/tests/src/Kernel/Views/ArgumentDateTimeTest.php \Drupal\Tests\datetime\Kernel\Views\ArgumentDateTimeTest::testDatetimeArgumentYear()
- 9 core/modules/datetime/tests/src/Kernel/Views/ArgumentDateTimeTest.php \Drupal\Tests\datetime\Kernel\Views\ArgumentDateTimeTest::testDatetimeArgumentYear()
Tests year argument.
See also
\Drupal\datetime\Plugin\views\argument\YearDate
File
- core/
modules/ datetime/ tests/ src/ Kernel/ Views/ ArgumentDateTimeTest.php, line 53
Class
- ArgumentDateTimeTest
- Tests the Drupal\datetime\Plugin\views\filter\Date handler.
Namespace
Drupal\Tests\datetime\Kernel\ViewsCode
public function testDatetimeArgumentYear() {
$view = Views::getView('test_argument_datetime');
// The 'default' display has the 'year' argument.
$view
->setDisplay('default');
$this
->executeView($view, [
'2000',
]);
$expected = [];
$expected[] = [
'nid' => $this->nodes[0]
->id(),
];
$this
->assertIdenticalResultset($view, $expected, $this->map);
$view
->destroy();
$view
->setDisplay('default');
$this
->executeView($view, [
'2002',
]);
$expected = [];
$expected[] = [
'nid' => $this->nodes[2]
->id(),
];
$this
->assertIdenticalResultset($view, $expected, $this->map);
$view
->destroy();
$view
->setDisplay('default');
$this
->executeView($view, [
'2003',
]);
$expected = [];
$expected[] = [
'nid' => $this->nodes[3]
->id(),
];
$this
->assertIdenticalResultset($view, $expected, $this->map);
$view
->destroy();
// Tests different system timezone with the same nodes.
$this
->setSiteTimezone('America/Vancouver');
$view
->setDisplay('default');
$this
->executeView($view, [
'2002',
]);
$expected = [];
// Only the 3rd node is returned here since UTC 2002-01-01T00:00:00 is still
// in 2001 for this user timezone.
$expected[] = [
'nid' => $this->nodes[3]
->id(),
];
$this
->assertIdenticalResultset($view, $expected, $this->map);
$view
->destroy();
}