summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/dblog/dblog.test2
-rw-r--r--modules/search/search.test8
-rw-r--r--modules/simpletest/drupal_web_test_case.php26
3 files changed, 16 insertions, 20 deletions
diff --git a/modules/dblog/dblog.test b/modules/dblog/dblog.test
index 0cfca13bf..585ae3440 100644
--- a/modules/dblog/dblog.test
+++ b/modules/dblog/dblog.test
@@ -181,7 +181,7 @@ class DBLogTestCase extends DrupalWebTestCase {
*/
private function doUser() {
// Set user variables.
- $name = $this->randomName();
+ $name = $this->randomName(4);
$pass = user_password();
// Add user using form to generate add user event (which is not triggered by drupalCreateUser).
$edit = array();
diff --git a/modules/search/search.test b/modules/search/search.test
index 28e83f49c..179e81a10 100644
--- a/modules/search/search.test
+++ b/modules/search/search.test
@@ -498,7 +498,7 @@ class SearchCommentTestCase extends DrupalWebTestCase {
* Verify that comments are rendered using proper format in search results.
*/
function testSearchResultsComment() {
- $comment_body = $this->randomName(5);
+ $comment_body = 'Test comment body';
variable_set('comment_preview_article', DRUPAL_OPTIONAL);
// Enable check_plain() for 'Filtered HTML' text format.
@@ -523,7 +523,7 @@ class SearchCommentTestCase extends DrupalWebTestCase {
$node = $this->drupalCreateNode(array('type' => 'article'));
// Post a comment using 'Full HTML' text format.
$edit_comment = array();
- $edit_comment['subject'] = $this->randomName(2);
+ $edit_comment['subject'] = 'Test comment subject';
$edit_comment['comment_body[' . LANGUAGE_NONE . '][0][value]'] = '<h1>' . $comment_body . '</h1>';
$edit_comment['comment_body[' . LANGUAGE_NONE . '][0][value_format]'] = 2;
$this->drupalPost('comment/reply/' . $node->nid, $edit_comment, t('Save'));
@@ -534,7 +534,7 @@ class SearchCommentTestCase extends DrupalWebTestCase {
// Search for the comment subject.
$edit = array(
- 'search_block_form' => $edit_comment['subject'],
+ 'search_block_form' => "'" . $edit_comment['subject'] . "'",
);
$this->drupalPost('', $edit, t('Search'));
$this->assertText($node->title, t('Node found in search results.'));
@@ -542,7 +542,7 @@ class SearchCommentTestCase extends DrupalWebTestCase {
// Search for the comment body.
$edit = array(
- 'search_block_form' => $comment_body,
+ 'search_block_form' => "'" . $comment_body . "'",
);
$this->drupalPost('', $edit, t('Search'));
$this->assertText($node->title, t('Node found in search results.'));
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;
}
-
}
/**