function RandomTest::testRandomStringUniqueness
Tests unique random string generation.
@covers ::string
      
    
File
- 
              core/tests/ Drupal/ Tests/ Component/ Utility/ RandomTest.php, line 33 
Class
- RandomTest
- Tests random data generation.
Namespace
Drupal\Tests\Component\UtilityCode
public function testRandomStringUniqueness() : void {
  $strings = [];
  $random = new Random();
  for ($i = 0; $i <= 50; $i++) {
    $str = $random->string(1, TRUE);
    $this->assertFalse(isset($strings[$str]), 'Generated duplicate random string ' . $str);
    $strings[$str] = TRUE;
  }
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
