1 backdrop_web_test_case.php protected BackdropWebTestCase::useCache()

Copies the cached tables and config for a profile if one is available.

Return value

TRUE when cache used, FALSE when cache is not available.:

See also

BackdropWebTestCase::setUp()

BackdropWebTestCase::tearDown()

File

core/modules/simpletest/backdrop_web_test_case.php, line 1590

Class

BackdropWebTestCase
Test case for typical Backdrop tests.

Code

protected function useCache() {
  $config_cache_dir = $this->originalFileDirectory . '/simpletest/simpletest_cache_' . $this->profile;

  if (is_dir($config_cache_dir)) {
    $prefix = 'simpletest_cache_' . $this->profile . '_';

    $tables = db_query("SHOW TABLES LIKE :prefix", array(':prefix' => db_like($prefix) . '%'))->fetchCol();

    foreach ($tables as $table_prefix) {
      $table = substr($table_prefix, strlen($prefix));
      db_query('CREATE TABLE ' . $this->databasePrefix . $table . ' LIKE ' . $table_prefix);
      db_query('INSERT ' . $this->databasePrefix . $table . ' SELECT * FROM ' . $table_prefix);
    }

    $this->recursiveCopy($config_cache_dir, $this->public_files_directory);

    return TRUE;
  }
  return FALSE;
}