From e99bc70d199be108eee5d5a2981cdcf3ccf43fe8 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Tue, 10 Oct 2023 19:09:46 +0100
Subject: [PATCH] Issue #3376563 by catch, alexpott, Spokje, Lendude, lauriii,
 longwave, Berdir: Random test fail in
 Drupal\Tests\Component\Utility\RandomTest::testRandomMachineNamesUniqueness

---
 .../Drupal/Tests/Component/Utility/RandomTest.php  | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
index e1682b67f5b7..aaa75d57285e 100644
--- a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
@@ -123,7 +123,7 @@ public function testRandomStringNonUnique() {
   public function testRandomMachineNamesUniqueness(): void {
     $names = [];
     $random = new Random();
-    for ($i = 0; $i <= 25; $i++) {
+    for ($i = 0; $i <= 10; $i++) {
       $str = $random->machineName(1, TRUE);
       $this->assertArrayNotHasKey($str, $names, 'Generated duplicate random name ' . $str);
       $names[$str] = TRUE;
@@ -194,17 +194,7 @@ public function testRandomStringValidator() {
    */
   public function testRandomWordValidator() {
     $random = new Random();
-    // Without a seed, test a different word is returned each time.
-    $this->firstStringGenerated = $random->word(5);
-    $next_str = $random->word(5);
-    $this->assertNotEquals($this->firstStringGenerated, $next_str);
-
-    // With a seed, test the same word is returned each time.
-    mt_srand(0);
-    $this->firstStringGenerated = $random->word(5);
-    mt_srand(0);
-    $next_str = $random->word(5);
-    $this->assertEquals($this->firstStringGenerated, $next_str);
+    $this->assertNotEquals($random->word(20), $random->word(20));
   }
 
   /**
-- 
GitLab