// Verify that the default formatter works.
$display_repository->
getViewDisplay($this->field->
getTargetEntityTypeId(),
$this->field->
getTargetBundle(), 'full'
) ->
setComponent($field_name,
$this->displayOptions
) ->
save();
$start_expected =
$this->dateFormatter->
format($start_date->
getTimestamp(), 'long', '', DateTimeItemInterface::STORAGE_TIMEZONE
);
$start_expected_iso =
$this->dateFormatter->
format($start_date->
getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DateTimeItemInterface::STORAGE_TIMEZONE
);
$start_expected_markup = '<time datetime="' .
$start_expected_iso . '">' .
$start_expected . '</time>';
$end_expected =
$this->dateFormatter->
format($end_date->
getTimestamp(), 'long', '', DateTimeItemInterface::STORAGE_TIMEZONE
);
$end_expected_iso =
$this->dateFormatter->
format($end_date->
getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DateTimeItemInterface::STORAGE_TIMEZONE
);
$end_expected_markup = '<time datetime="' .
$end_expected_iso . '">' .
$end_expected . '</time>';
$output =
$this->
renderTestEntity($id);
$this->
assertStringContainsString($start_expected_markup,
$output,
new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute in %timezone.',
[ '%value' => 'long',
'%expected' =>
$start_expected,
'%expected_iso' =>
$start_expected_iso,
'%timezone' =>
$timezone,
]));
$this->
assertStringContainsString($end_expected_markup,
$output,
new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute in %timezone.',
[ '%value' => 'long',
'%expected' =>
$end_expected,
'%expected_iso' =>
$end_expected_iso,
'%timezone' =>
$timezone,
]));