function DrupalWebTestCase::copySetupCache
Copy the setup cache from/to another table and files directory.
Parameters
string $from: The prefix_id / cache_key from where to copy.
string $to: The prefix_id / cache_key to where to copy.
Return value
bool TRUE if the setup cache was copied to the current installation, FALSE otherwise.
2 calls to DrupalWebTestCase::copySetupCache()
- DrupalWebTestCase::loadSetupCache in modules/
simpletest/ drupal_web_test_case.php - Copies the cached tables and files for a cached installation setup.
- DrupalWebTestCase::storeSetupCache in modules/
simpletest/ drupal_web_test_case.php - Store the installation setup to a cache.
File
-
modules/
simpletest/ drupal_web_test_case.php, line 1618
Class
- DrupalWebTestCase
- Test case for typical Drupal tests.
Code
protected function copySetupCache($from, $to) {
$from_prefix = 'simpletest' . $from;
$to_prefix = 'simpletest' . $to;
try {
$tables = db_query("SHOW TABLES LIKE :prefix", array(
':prefix' => db_like($from_prefix) . '%',
))->fetchCol();
if (count($tables) == 0) {
return FALSE;
}
foreach ($tables as $from_table) {
$table = substr($from_table, strlen($from_prefix));
$to_table = $to_prefix . $table;
// Remove the table in case the copying process was interrupted.
db_query('DROP TABLE IF EXISTS ' . $to_table);
db_query('CREATE TABLE ' . $to_table . ' LIKE ' . $from_table);
db_query('ALTER TABLE ' . $to_table . ' DISABLE KEYS');
db_query('INSERT ' . $to_table . ' SELECT * FROM ' . $from_table);
db_query('ALTER TABLE ' . $to_table . ' ENABLE KEYS');
}
} catch (Exception $e) {
return FALSE;
}
$from_dir = $this->originalFileDirectory . '/simpletest/' . $from;
$to_dir = $this->originalFileDirectory . '/simpletest/' . $to;
$this->recursiveDirectoryCopy($from_dir, $to_dir);
return TRUE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.