public function RandomTest::testRandomNameException 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::testRandomNameException()
Tests infinite loop prevention whilst generating random names.
@covers ::name @expectedException \RuntimeException
File
- core/
tests/ Drupal/ Tests/ Component/ Utility/ RandomTest.php, line 67 - Contains \Drupal\Tests\Component\Utility\RandomTest.
Class
- RandomTest
- Tests random data generation.
Namespace
Drupal\Tests\Component\UtilityCode
public function testRandomNameException() {
// There are fewer than 100 possibilities so an exception should occur to
// prevent infinite loops.
$random = new Random();
for ($i = 0; $i <= 100; $i++) {
$str = $random
->name(1, TRUE);
$names[$str] = TRUE;
}
}