DrupalWebTestCase::preloadRegistry

  1. drupal
    1. 8
    2. 7
Versions
7 protected DrupalWebTestCase::preloadRegistry()

Preload the registry from the testing site.

This method is called by DrupalWebTestCase::setUp(), and preloads the registry from the testing site to cut down on the time it takes to set up a clean environment for the current test run.

Code

modules/simpletest/drupal_web_test_case.php, line 1369

<?php
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');
  $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();
  }
}
?>