You are here

public static function DrupalTestCase::randomString in SimpleTest 7.2

Same name and namespace in other branches
  1. 6.2 drupal_web_test_case.php \DrupalTestCase::randomString()
  2. 7 drupal_web_test_case.php \DrupalTestCase::randomString()

Generates a random string of ASCII characters of codes 32 to 126.

The generated string includes alpha-numeric characters and common misc characters. Use this method when testing general input where the content is not restricted.

Parameters

$length: Length of random string to generate.

Return value

Randomly generated string.

2 calls to DrupalTestCase::randomString()
DrupalRemoteTestCase::randomString in ./drupal_web_test_case.php
Add remote prefix.
SimpleTestMailCaptureTestCase::testMailSend in ./simpletest.test
Test to see if the wrapper function is executed correctly.
1 method overrides DrupalTestCase::randomString()
DrupalRemoteTestCase::randomString in ./drupal_web_test_case.php
Add remote prefix.

File

./drupal_web_test_case.php, line 554
Provides DrupalTestCase, DrupalUnitTestCase, and DrupalWebTestCase classes.

Class

DrupalTestCase
Base class for Drupal tests.

Code

public static function randomString($length = 8) {
  $str = '';
  for ($i = 0; $i < $length; $i++) {
    $str .= chr(mt_rand(32, 126));
  }
  return $str;
}