protected function FieldDateTest::assertRenderedDatesEqual in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Kernel/Handler/FieldDateTest.php \Drupal\Tests\views\Kernel\Handler\FieldDateTest::assertRenderedDatesEqual()
Asserts properly formatted display against 'created' field in view.
Parameters
mixed $view: View to be tested.
array $map: Data map.
null $timezone: Optional timezone.
1 call to FieldDateTest::assertRenderedDatesEqual()
- FieldDateTest::testFieldDate in core/
modules/ views/ tests/ src/ Kernel/ Handler/ FieldDateTest.php - Sets up functional test of the views date field.
File
- core/
modules/ views/ tests/ src/ Kernel/ Handler/ FieldDateTest.php, line 154
Class
- FieldDateTest
- Tests the core Drupal\views\Plugin\views\field\Date handler.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
protected function assertRenderedDatesEqual($view, $map, $timezone = NULL) {
foreach ($map as $date_format => $expected_result) {
$view->field['created']->options['date_format'] = $date_format;
$t_args = [
'%value' => $expected_result,
'%format' => $date_format,
];
if (isset($timezone)) {
$t_args['%timezone'] = $timezone;
$message = t('Value %value in %format format for timezone %timezone matches.', $t_args);
$view->field['created']->options['timezone'] = $timezone;
}
else {
$message = t('Value %value in %format format matches.', $t_args);
}
$actual_result = $view->field['created']
->advancedRender($view->result[0]);
$this
->assertEquals($expected_result, $actual_result, $message);
}
}