diff options
Diffstat (limited to 'modules/simpletest/drupal_web_test_case.php')
-rw-r--r-- | modules/simpletest/drupal_web_test_case.php | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index e9d5ad43d..841451746 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -1313,9 +1313,32 @@ class DrupalWebTestCase extends DrupalTestCase { * set up a clean environment for the current test run. */ protected function preloadRegistry() { + // Use two separate queries, each with their own connections: copy the + // {registry} and {registry_file} tables over from the parent installation + // to the child installation. $original_connection = Database::getConnection('default', 'simpletest_original_default'); - db_query('INSERT INTO {registry} SELECT * FROM ' . $original_connection->prefixTables('{registry}')); - db_query('INSERT INTO {registry_file} SELECT * FROM ' . $original_connection->prefixTables('{registry_file}')); + $test_connection = Database::getConnection(); + + foreach (array('registry', 'registry_file') as $table) { + // Find the records from the parent database. + $source_query = $original_connection + ->select($table, array(), array('fetch' => PDO::FETCH_ASSOC)) + ->fields($table); + + $dest_query = $test_connection->insert($table); + + $first = TRUE; + foreach ($source_query->execute() as $row) { + if ($first) { + $dest_query->fields(array_keys($row)); + $first = FALSE; + } + // Insert the records into the child database. + $dest_query->values($row); + } + + $dest_query->execute(); + } } /** |