You are here

protected static function PageExampleTestCase::randomNumber in Examples for Developers 7

Same name and namespace in other branches
  1. 6 page_example/page_example.test \PageExampleTestCase::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 PageExampleTestCase::randomNumber()
PageExampleTestCase::testPageExampleBasic in page_example/page_example.test
Functional test for various page types.

File

page_example/page_example.test, line 46
Test case for Testing the page example module.

Class

PageExampleTestCase
Functional tests for the Page Example module.

Code

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