protected static function PageExampleTest::randomNumber in Examples for Developers 8
Same name and namespace in other branches
- 3.x modules/page_example/tests/src/Functional/PageExampleTest.php \Drupal\Tests\page_example\Functional\PageExampleTest::randomNumber()
Generates a random string of ASCII numeric characters (values 48 to 57).
Parameters
int $length: Length of random string to generate.
Return value
string Randomly generated string.
1 call to PageExampleTest::randomNumber()
- PageExampleTest::testPageExample in page_example/
tests/ src/ Functional/ PageExampleTest.php - Main test.
File
- page_example/
tests/ src/ Functional/ PageExampleTest.php, line 54
Class
- PageExampleTest
- Creates page and render the content based on the arguments passed in the URL.
Namespace
Drupal\Tests\page_example\FunctionalCode
protected static function randomNumber($length = 8) {
$str = '';
for ($i = 0; $i < $length; $i++) {
$str .= chr(mt_rand(48, 57));
}
return $str;
}