diff --git a/drupal_web_test_case.php b/drupal_web_test_case.php index ec11ca3..7d118a6 100644 --- a/drupal_web_test_case.php +++ b/drupal_web_test_case.php @@ -3422,6 +3422,11 @@ class DrupalWebTestCase extends DrupalTestCase { * Clone an existing database and use it for testing. */ class DrupalCloneTestCase extends DrupalWebTestCase { + /** + * Information about existing database tables. + */ + protected $sources = array(); + protected $schemas = array(); /** * Tables to exlude during data cloning, only their structure will be cloned. @@ -3442,28 +3447,23 @@ class DrupalCloneTestCase extends DrupalWebTestCase { 'cache_update', 'watchdog', ); - - protected function setUpInstall(array $modules, $public_files_directory, $private_files_directory, $temp_files_directory) { - global $db_prefix; - - // Store new database prefix. - $db_prefix_new = $db_prefix; - $db_prefix = $this->originalPrefix; - + protected function setUp() { // Rebuild schema based on prefixed database and such. - $schemas = drupal_get_schema(NULL, TRUE); + $this->schemas = drupal_get_schema(NULL, TRUE); + // Create a list of prefixed source table names. - $sources = array(); - foreach ($schemas as $name => $schema) { - $sources[$name] = Database::getConnection()->prefixTables('{' . $name . '}'); + $this->sources = array(); + foreach ($this->schemas as $name => $schema) { + $this->sources[$name] = Database::getConnection()->prefixTables('{' . $name . '}'); } - // Return to new prefix before performing cloning. - $db_prefix = $db_prefix_new; + parent::setUp(); + } + protected function setUpInstall(array $modules, $public_files_directory, $private_files_directory, $temp_files_directory) { // Clone each table into the new database. - foreach ($schemas as $name => $schema) { - $this->cloneTable($name, $sources[$name], $schema); + foreach ($this->schemas as $name => $schema) { + $this->cloneTable($name, $this->sources[$name], $schema); } }