You are here

protected static function FaqTestCase::randomNumber in Frequently Asked Questions 6

Same name and namespace in other branches
  1. 7.2 faq.test \FaqTestCase::randomNumber()
  2. 7 faq.test \FaqTestCase::randomNumber()

Generates a random string of ASCII numeric characters (values 48 to 57).

Parameters

$length: Length of random string to generate .

Return value

Randomly generated string.

File

./faq.test, line 70
Test FAQ functionality Base test class. All tests inherits this one. Hugely based on code from the test file block.test by boombatower

Class

FaqTestCase
Base class that is extended by test cases.

Code

protected static function randomNumber($length = 8) {
  $str = '';
  for ($i = 0; $i < $length; $i++) {
    $str .= chr(mt_rand(48, 57));
  }
  return $str;
}