protected function DrupalCloneTestCase::setUpInstall in SimpleTest 7.2
Perform Drupal installation.
Overrides DrupalWebTestCase::setUpInstall
File
- ./
drupal_web_test_case.php, line 3446 - Provides DrupalTestCase, DrupalUnitTestCase, and DrupalWebTestCase classes.
Class
- DrupalCloneTestCase
- Clone an existing database and use it for testing.
Code
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;
// Rebuild schema based on prefixed database and such.
$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 . '}');
}
// Return to new prefix before performing cloning.
$db_prefix = $db_prefix_new;
// Clone each table into the new database.
foreach ($schemas as $name => $schema) {
$this
->cloneTable($name, $sources[$name], $schema);
}
}