You are here

protected function BrowserTestBase::cleanupEnvironment in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::cleanupEnvironment()

Clean up the Simpletest environment.

1 call to BrowserTestBase::cleanupEnvironment()
BrowserTestBase::tearDown in core/tests/Drupal/Tests/BrowserTestBase.php

File

core/tests/Drupal/Tests/BrowserTestBase.php, line 443

Class

BrowserTestBase
Provides a test case for functional Drupal tests.

Namespace

Drupal\Tests

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.
  \Drupal::service('file_system')
    ->deleteRecursive($this->siteDirectory, [
    $this,
    'filePreDeleteCallback',
  ]);
}