You are here

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

Same name and namespace in other branches
  1. 6 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 76
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;
}