diff --git a/core/modules/simpletest/src/RandomGeneratorTrait.php b/core/modules/simpletest/src/RandomGeneratorTrait.php
index 70087ce..67a663e 100644
--- a/core/modules/simpletest/src/RandomGeneratorTrait.php
+++ b/core/modules/simpletest/src/RandomGeneratorTrait.php
@@ -8,6 +8,7 @@
 namespace Drupal\simpletest;
 
 use Drupal\Component\Utility\Random;
+use Drupal\Component\Utility\Unicode;
 
 /**
  * Provides random generator utility methods.
@@ -89,14 +90,36 @@ public function randomStringValidate($string) {
    *
    * @param int $length
    *   Length of random string to generate.
+   * @param bool $lowercase
+   *   (optional) If the generated machine name is forced to lowercase. Defaults
+   *   to FALSE.
    *
    * @return string
    *   Randomly generated unique string.
    *
    * @see \Drupal\Component\Utility\Random::name()
    */
-  protected function randomMachineName($length = 8) {
-    return $this->getRandomGenerator()->name($length, TRUE);
+  protected function randomMachineName($length = 8, $lowercase = FALSE) {
+    $machine_name = $this->getRandomGenerator()->name($length, TRUE);
+    return $lowercase ? Unicode::strtolower($machine_name) : $machine_name;
+  }
+
+  /**
+   * Generates a unique lowercase random string containing letters and numbers.
+   *
+   * Do not use this method when testing unvalidated user input. Instead, use
+   * \Drupal\simpletest\TestBase::randomString().
+   *
+   * @param int $length
+   *   Length of random string to generate.
+   *
+   * @return string
+   *   Randomly generated unique string.
+   *
+   * @see \Drupal\simpletest\RandomGeneratorTrait::randomMachineName()
+   */
+  protected function randomLowercaseMachineName($length = 8) {
+    return $this->randomMachineName($length, TRUE);
   }
 
   /**
diff --git a/core/modules/system/src/Tests/System/DateFormatsMachineNameTest.php b/core/modules/system/src/Tests/System/DateFormatsMachineNameTest.php
index a273515..f06f3f7 100644
--- a/core/modules/system/src/Tests/System/DateFormatsMachineNameTest.php
+++ b/core/modules/system/src/Tests/System/DateFormatsMachineNameTest.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\system\Tests\System;
 
-use Drupal\Component\Utility\Unicode;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -61,7 +60,7 @@ public function testDateFormatsMachineNameAllowedValues() {
     $this->assertText(t('The machine-readable name is already in use. It must be unique.'), 'It is not possible to create a date format with the machine name "fallback". It is a built-in format that already exists.');
 
     // Create a date format with a machine name distinct from the previous two.
-    $id = Unicode::strtolower($this->randomMachineName(16));
+    $id = $this->randomLowercaseMachineName(16);
     $edit = array(
       'label' => $this->randomMachineName(16),
       'id' => $id,
