Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / datetime / tests / src / Functional / DateTestBase.php
index 369e793343d4ee115a0bbbbe9c53e7580484bc0d..46e23ce150327dbc81687fcd2e76d4b12d49267f 100644 (file)
@@ -106,7 +106,8 @@ abstract class DateTestBase extends BrowserTestBase {
    * 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';
 
@@ -119,8 +120,9 @@ abstract class DateTestBase extends BrowserTestBase {
     $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();
@@ -181,4 +183,20 @@ abstract class DateTestBase extends BrowserTestBase {
       ->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();
+    }
+  }
+
 }