You are here

protected function BrowserTestBase::cleanupEnvironment in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/BrowserTestBase.php \Drupal\simpletest\BrowserTestBase::cleanupEnvironment()

Clean up the Simpletest environment.

1 call to BrowserTestBase::cleanupEnvironment()
BrowserTestBase::tearDown in core/modules/simpletest/src/BrowserTestBase.php

File

core/modules/simpletest/src/BrowserTestBase.php, line 377
Contains \Drupal\simpletest\BrowserTestBase.

Class

BrowserTestBase
Provides a test case for functional Drupal tests.

Namespace

Drupal\simpletest

Code

protected function cleanupEnvironment() {

  // Remove all prefixed tables.
  $original_connection_info = Database::getConnectionInfo('simpletest_original_default');
  $original_prefix = $original_connection_info['default']['prefix']['default'];
  $test_connection_info = Database::getConnectionInfo('default');
  $test_prefix = $test_connection_info['default']['prefix']['default'];
  if ($original_prefix != $test_prefix) {
    $tables = Database::getConnection()
      ->schema()
      ->findTables('%');
    foreach ($tables as $table) {
      if (Database::getConnection()
        ->schema()
        ->dropTable($table)) {
        unset($tables[$table]);
      }
    }
  }

  // Delete test site directory.
  file_unmanaged_delete_recursive($this->siteDirectory, array(
    $this,
    'filePreDeleteCallback',
  ));
}