* Creates a date test field.
*/
protected function createField() {
- $field_name = Unicode::strtolower($this->randomMachineName());
+ $field_name = mb_strtolower($this->randomMachineName());
+ $field_label = Unicode::ucfirst(mb_strtolower($this->randomMachineName()));
$type = $this->getTestFieldType();
$widget_type = $formatter_type = $type . '_default';
$this->fieldStorage->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
+ 'label' => $field_label,
'bundle' => 'entity_test',
- 'description' => 'Description for ' . $field_name,
+ 'description' => 'Description for ' . $field_label,
'required' => TRUE,
]);
$this->field->save();
->save();
}
+ /**
+ * Massages test date values.
+ *
+ * If a date object is generated directly by a test, then it needs to be
+ * adjusted to behave like the computed date from the item.
+ *
+ * @param \Drupal\Core\Datetime\DrupalDateTime $date
+ * A date object directly generated by the test.
+ */
+ protected function massageTestDate($date) {
+ if ($this->field->getSetting('datetime_type') === DateTimeItem::DATETIME_TYPE_DATE) {
+ // Set the default time for date-only items.
+ $date->setDefaultDateTime();
+ }
+ }
+
}