You are here

public static function AcquiaSearchUnitTestCase::randomAcquiaSearchName in Acquia Search 6.3

Original randomName function of simpletest did not produce correct results so we backported the Drupal 7 simpletest function to Drupal 6 to genuinely test the exact same scenario.

Parameters

type $length:

Return value

string

3 calls to AcquiaSearchUnitTestCase::randomAcquiaSearchName()
AcquiaSearchUnitTestCase::setUp in tests/acquia_search.test
Overrides DrupalTestCase::setUp().
AcquiaSearchUnitTestCase::testHMACCookie in tests/acquia_search.test
Tests HMAC generation.
AcquiaSearchWebTestCase::setUp in tests/acquia_search.test
Overrides DrupalTestCase::setUp().

File

tests/acquia_search.test, line 67

Class

AcquiaSearchUnitTestCase
Unit tests of the functionality of the Acquia Search module.

Code

public static function randomAcquiaSearchName($length = 8) {
  $values = array_merge(range(65, 90), range(97, 122), range(48, 57));
  $max = count($values) - 1;
  $str = chr(mt_rand(97, 122));
  for ($i = 1; $i < $length; $i++) {
    $str .= chr($values[mt_rand(0, $max)]);
  }
  return $str;
}