$root =
dirname(__DIR__, 5
);
$database = Database::
convertDbUrlToConnectionInfo($db_url,
$root);
$database['prefix'
] =
$test_database->
getDatabasePrefix();
Database::
addConnectionInfo(__CLASS__, 'default',
$database);
// Remove all the tables.
$schema = Database::
getConnection('default', __CLASS__
)->
schema();
$tables =
$schema->
findTables('%'
);
array_walk($tables,
[$schema, 'dropTable'
]);
// Delete test site directory.
$this->
fileUnmanagedDeleteRecursive($root . DIRECTORY_SEPARATOR .
$test_database->
getTestSitePath(),
[BrowserTestBase::
class, 'filePreDeleteCallback'
]);
} /**
* Deletes all files and directories in the specified path recursively.
*
* Note this method has no dependencies on Drupal core to ensure that the
* test site can be torn down even if something in the test site is broken.
*
* @param string $path
* A string containing either a URI or a file or directory path.
* @param callable $callback
* (optional) Callback function to run on each file prior to deleting it and
* on each directory prior to traversing it. For example, can be used to
* modify permissions.
*
* @return bool
* TRUE for success or if path does not exist, FALSE in the event of an
* error.
*
* @see \Drupal\Core\File\FileSystemInterface::deleteRecursive()
*/