public function RandomTest::testRandomNamesUniqueness in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Component/Utility/RandomTest.php \Drupal\Tests\Component\Utility\RandomTest::testRandomNamesUniqueness()
Tests unique random name generation.
@covers ::name
File
- core/
tests/ Drupal/ Tests/ Component/ Utility/ RandomTest.php, line 51 - Contains \Drupal\Tests\Component\Utility\RandomTest.
Class
- RandomTest
- Tests random data generation.
Namespace
Drupal\Tests\Component\UtilityCode
public function testRandomNamesUniqueness() {
$names = array();
$random = new Random();
for ($i = 0; $i <= 10; $i++) {
$str = $random
->name(1, TRUE);
$this
->assertFalse(isset($names[$str]), 'Generated duplicate random name ' . $str);
$names[$str] = TRUE;
}
}