function RandomTest::testRandomMachineNameException
Same name in other branches
- 11.x core/tests/Drupal/Tests/Component/Utility/RandomTest.php \Drupal\Tests\Component\Utility\RandomTest::testRandomMachineNameException()
Tests infinite loop prevention whilst generating random names.
@covers ::machineName
File
-
core/
tests/ Drupal/ Tests/ Component/ Utility/ RandomTest.php, line 140
Class
- RandomTest
- Tests random data generation.
Namespace
Drupal\Tests\Component\UtilityCode
public function testRandomMachineNameException() : void {
// There are fewer than 100 possibilities so an exception should occur to
// prevent infinite loops.
$this->expectException(\RuntimeException::class);
$random = new Random();
for ($i = 0; $i <= 100; $i++) {
$random->machineName(1, TRUE);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.