summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-02-26 17:22:39 +0000
committerDries Buytaert <dries@buytaert.net>2010-02-26 17:22:39 +0000
commitbc70eaeb8ddd78022ea6831ccb2e49b9cb653069 (patch)
tree8373a768f871e4e36cab74e70d26253dbdbe3b45 /modules/simpletest
parent19aaebcbe2fe4af1e9fbf47c6e498889bbd9f934 (diff)
downloadbrdo-bc70eaeb8ddd78022ea6831ccb2e49b9cb653069.tar.gz
brdo-bc70eaeb8ddd78022ea6831ccb2e49b9cb653069.tar.bz2
- Patch #535440 by andypost, carlos8f, boombatower: random strings in SimpleTest should not contain
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/drupal_web_test_case.php26
1 files changed, 11 insertions, 15 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index befb5155e..5a364f9b9 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -505,45 +505,41 @@ abstract class DrupalTestCase {
* is not restricted.
*
* @param $length
- * Length of random string to generate which will be appended to $db_prefix.
+ * Length of random string to generate.
* @return
* Randomly generated string.
*/
public static function randomString($length = 8) {
- global $db_prefix;
-
$str = '';
for ($i = 0; $i < $length; $i++) {
$str .= chr(mt_rand(32, 126));
}
- return str_replace('simpletest', 's', $db_prefix) . $str;
+ return $str;
}
/**
* Generates a random string containing letters and numbers.
*
- * The letters may be upper or lower case. This method is better for
- * restricted inputs that do not accept certain characters. For example,
- * when testing input fields that require machine readable values (ie without
- * spaces and non-standard characters) this method is best.
+ * The string will always start with a letter. The letters may be upper or
+ * lower case. This method is better for restricted inputs that do not
+ * accept certain characters. For example, when testing input fields that
+ * require machine readable values (i.e. without spaces and non-standard
+ * characters) this method is best.
*
* @param $length
- * Length of random string to generate which will be appended to $db_prefix.
+ * Length of random string to generate.
* @return
* Randomly generated string.
*/
public static function randomName($length = 8) {
- global $db_prefix;
-
$values = array_merge(range(65, 90), range(97, 122), range(48, 57));
$max = count($values) - 1;
- $str = '';
- for ($i = 0; $i < $length; $i++) {
+ $str = chr(mt_rand(97, 122));
+ for ($i = 1; $i < $length; $i++) {
$str .= chr($values[mt_rand(0, $max)]);
}
- return str_replace('simpletest', 's', $db_prefix) . $str;
+ return $str;
}
-
}
/**