summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-11-01 21:21:35 +0000
committerDries Buytaert <dries@buytaert.net>2008-11-01 21:21:35 +0000
commitfa94c66c92eaec0a636fa4f92b8496f7c38fc54a (patch)
treee4256186f9897e9b062cf7bb9d5bd84170182bb8
parent424250196a65b48919de50b2a3327f67c076e0d3 (diff)
downloadbrdo-fa94c66c92eaec0a636fa4f92b8496f7c38fc54a.tar.gz
brdo-fa94c66c92eaec0a636fa4f92b8496f7c38fc54a.tar.bz2
- Patch #328719 by c960657: make the module list tests succeed again.
-rw-r--r--includes/common.inc4
-rw-r--r--includes/database/database.inc2
-rw-r--r--modules/simpletest/drupal_web_test_case.php6
-rw-r--r--modules/simpletest/simpletest.module9
-rw-r--r--modules/simpletest/tests/common.test1
-rw-r--r--modules/system/system.test2
6 files changed, 15 insertions, 9 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 7b2dda038..df2b8e1d2 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -497,8 +497,8 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
// user-agent is used to ensure that multiple testing sessions running at the
// same time won't interfere with each other as they would if the database
// prefix were stored statically in a file or database variable.
- if (preg_match("/^simpletest\d+/", $db_prefix)) {
- $headers['User-Agent'] = $db_prefix;
+ if (preg_match("/simpletest\d+/", $db_prefix, $matches)) {
+ $headers['User-Agent'] = $matches[0];
}
foreach ($headers as $header => $value) {
diff --git a/includes/database/database.inc b/includes/database/database.inc
index 0f64dfb61..31d98b4b3 100644
--- a/includes/database/database.inc
+++ b/includes/database/database.inc
@@ -1005,7 +1005,7 @@ abstract class Database {
// We need to pass around the simpletest database prefix in the request
// and we put that in the user_agent header.
if (preg_match("/^simpletest\d+$/", $_SERVER['HTTP_USER_AGENT'])) {
- $db_prefix = $_SERVER['HTTP_USER_AGENT'];
+ $db_prefix .= $_SERVER['HTTP_USER_AGENT'];
}
// Return the target that was actually opened in case the requested one
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index e63a3442e..2a0c38c26 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -689,7 +689,7 @@ class DrupalWebTestCase {
$clean_url_original = variable_get('clean_url', 0);
// Generate temporary prefixed database to ensure that tests have a clean starting point.
- $db_prefix = 'simpletest' . mt_rand(1000, 1000000);
+ $db_prefix = Database::getActiveConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
include_once DRUPAL_ROOT . '/includes/install.inc';
drupal_install_system();
@@ -800,8 +800,8 @@ class DrupalWebTestCase {
CURLOPT_SSL_VERIFYPEER => FALSE, // Required to make the tests run on https://
CURLOPT_SSL_VERIFYHOST => FALSE, // Required to make the tests run on https://
);
- if (preg_match('/simpletest\d+/', $db_prefix)) {
- $curl_options[CURLOPT_USERAGENT] = $db_prefix;
+ if (preg_match('/simpletest\d+/', $db_prefix, $matches)) {
+ $curl_options[CURLOPT_USERAGENT] = $matches[0];
}
if (!isset($curl_options[CURLOPT_USERPWD]) && ($auth = variable_get('simpletest_httpauth_username', ''))) {
if ($pass = variable_get('simpletest_httpauth_pass', '')) {
diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module
index 896b64f61..5275afb67 100644
--- a/modules/simpletest/simpletest.module
+++ b/modules/simpletest/simpletest.module
@@ -514,11 +514,16 @@ function simpletest_clean_environment() {
* Removed prefixed talbes from the database that are left over from crashed tests.
*/
function simpletest_clean_database() {
- $tables = db_find_tables(Database::getActiveConnection()->prefixTables('simpletest') . '%');
+ global $db_prefix;
+ $tables = db_find_tables(Database::getActiveConnection()->prefixTables('{simpletest}') . '%');
$schema = drupal_get_schema_unprocessed('simpletest');
$ret = array();
foreach (array_diff_key($tables, $schema) as $table) {
- db_drop_table($ret, $table);
+ // Strip $db_prefix and skip tables without digits following "simpletest",
+ // e.g. {simpletest_tets_id}.
+ if (preg_match('/simpletest\d+.*/', $table, $matches)) {
+ db_drop_table($ret, $matches[0]);
+ }
}
if (count($ret) > 0) {
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index 6a82018db..b7ebac4ff 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -321,6 +321,7 @@ class JavaScriptTestCase extends DrupalWebTestCase {
* Implementation of setUp().
*/
function setUp() {
+ parent::setUp();
// Reset drupal_add_js() before each test.
drupal_add_js(NULL, NULL, TRUE);
}
diff --git a/modules/system/system.test b/modules/system/system.test
index d3814aa8a..8db303a06 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -118,7 +118,7 @@ class EnableDisableCoreTestCase extends DrupalWebTestCase {
* @return boolean Tables with specified base table.
*/
function assertTableCount($base_table, $count) {
- $tables = db_find_tables(Database::getActiveConnection()->prefixTables($base_table) . '%');
+ $tables = db_find_tables(Database::getActiveConnection()->prefixTables('{' . $base_table . '}') . '%');
if ($count) {
return $this->assertTrue($tables, t('Tables matching "@base_table" found.', array('@base_table' => $base_table)));