// Make sure the "datetime_timestamp" widget is on the page.
$this->
assertSession()->
elementsCount('xpath', '//div[contains(@class, "field--widget-datetime-timestamp") and @id="edit-field-timestamp-wrapper"]', 1
);
// Look for the widget elements and make sure they are empty.
$this->
assertSession()->
fieldExists('field_timestamp[0][value][date]'
);
$this->
assertSession()->
fieldValueEquals('field_timestamp[0][value][date]', ''
);
$this->
assertSession()->
fieldExists('field_timestamp[0][value][time]'
);
$this->
assertSession()->
fieldValueEquals('field_timestamp[0][value][time]', ''
);
// Submit the date.
$date_format = DateFormat::
load('html_date'
)->
getPattern();
$time_format = DateFormat::
load('html_time'
)->
getPattern();
$edit =
[ 'field_timestamp[0][value][date]' =>
$date->
format($date_format),
'field_timestamp[0][value][time]' =>
$date->
format($time_format),
];
$this->
submitForm($edit, 'Save'
);
// Make sure the submitted date is set as the default in the widget.
$this->
assertSession()->
fieldExists('field_timestamp[0][value][date]'
);
$this->
assertSession()->
fieldValueEquals('field_timestamp[0][value][date]',
$date->
format($date_format));