function DrupalTestCase::randomName in SimpleTest 5
Same name and namespace in other branches
- 6.2 drupal_web_test_case.php \DrupalTestCase::randomName()
- 6 drupal_test_case.php \DrupalTestCase::randomName()
- 7.2 drupal_web_test_case.php \DrupalTestCase::randomName()
- 7 drupal_web_test_case.php \DrupalTestCase::randomName()
Generates a random string, to be used as name or whatever
Parameters
integer $number number of characters:
Return value
ransom string
21 calls to DrupalTestCase::randomName()
- DrupalTestCase::drupalCreateRolePerm in ./
drupal_test_case.php - Create a role / perm combination specified by permissions
- DrupalTestCase::drupalCreateUserRolePerm in ./
drupal_test_case.php - Creates a user / role / permissions combination specified by permissions
- ImageModuleTest::testImageNode in tests/
image_module.test - PageCreationTest::testPageCreation in tests/
page_creation.test - PageViewTest::testPageView in tests/
page_view.test
File
- ./
drupal_test_case.php, line 157
Class
- DrupalTestCase
- Test case for typical Drupal tests. Extends WebTestCase for comfortable browser usage but also implements all UnitTestCase methods, I wish WebTestCase would do this.
Code
function randomName($number = 4, $prefix = 'simpletest_') {
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_';
for ($x = 0; $x < $number; $x++) {
$prefix .= $chars[mt_rand(0, strlen($chars) - 1)];
if ($x == 0) {
$chars .= '0123456789';
}
}
return $prefix;
}