public function ArgumentDateTest::testYearHandler in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Kernel/Handler/ArgumentDateTest.php \Drupal\Tests\views\Kernel\Handler\ArgumentDateTest::testYearHandler()
Tests the Year handler.
See also
\Drupal\node\Plugin\views\argument\CreatedYear
File
- core/
modules/ views/ tests/ src/ Kernel/ Handler/ ArgumentDateTest.php, line 222
Class
- ArgumentDateTest
- Tests the core date argument handlers.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
public function testYearHandler() {
$this->container
->get('database')
->update('views_test_data')
->fields([
'created' => gmmktime(0, 0, 0, 1, 1, 2001),
])
->condition('id', 3)
->execute();
$this->container
->get('database')
->update('views_test_data')
->fields([
'created' => gmmktime(0, 0, 0, 1, 1, 2002),
])
->condition('id', 4)
->execute();
$this->container
->get('database')
->update('views_test_data')
->fields([
'created' => gmmktime(0, 0, 0, 1, 1, 2002),
])
->condition('id', 5)
->execute();
$view = Views::getView('test_argument_date');
$view
->setDisplay('embed_4');
$this
->executeView($view, [
'2000',
]);
$expected = [];
$expected[] = [
'id' => 1,
];
$expected[] = [
'id' => 2,
];
$this
->assertIdenticalResultset($view, $expected, $this->columnMap);
$view
->destroy();
$view
->setDisplay('embed_4');
$this
->executeView($view, [
'2001',
]);
$expected = [];
$expected[] = [
'id' => 3,
];
$this
->assertIdenticalResultset($view, $expected, $this->columnMap);
$view
->destroy();
$view
->setDisplay('embed_4');
$this
->executeView($view, [
'2002',
]);
$expected = [];
$expected[] = [
'id' => 4,
];
$expected[] = [
'id' => 5,
];
$this
->assertIdenticalResultset($view, $expected, $this->columnMap);
$view
->destroy();
$view
->setDisplay('embed_4');
$this
->executeView($view, [
'23',
]);
$expected = [];
$this
->assertIdenticalResultset($view, $expected, $this->columnMap);
}