diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php index eaa545c..95b9291 100644 --- a/core/modules/simpletest/src/KernelTestBase.php +++ b/core/modules/simpletest/src/KernelTestBase.php @@ -193,6 +193,20 @@ protected function setUp() { } $this->kernel->boot(); + // Ensure database tasks have been run. + require_once __DIR__ . '/../../../includes/install.inc'; + $connection = Database::getConnection(); + $errors = db_installer_object($connection->driver())->runTasks(); + if (!empty($errors)) { + $this->fail('Failed to run installer database tasks: ' . implode(', ', $errors)); + } + + // After running the database tasks we have to reboot the container so that + // a new database connection is created. + $this->kernel->shutdown(); + $this->kernel->boot(); + + // Save the original site directory path, so that extensions in the // site-specific directory can still be discovered in the test site // environment. @@ -208,7 +222,6 @@ protected function setUp() { $this->prepareConfigDirectories(); // Set the request scope. - $this->container = $this->kernel->getContainer(); $this->container->get('request_stack')->push($request); // Re-inject extension file listings into state, unless the key/value @@ -225,14 +238,6 @@ protected function setUp() { // the event dispatcher which can prevent modules from registering events. \Drupal::service('config.storage')->write('core.extension', array('module' => array(), 'theme' => array())); - // Ensure database tasks have been run. - require_once __DIR__ . '/../../../includes/install.inc'; - $connection = Database::getConnection(); - $errors = db_installer_object($connection->driver())->runTasks(); - if (!empty($errors)) { - $this->fail('Failed to run installer database tasks: ' . implode(', ', $errors)); - } - // Collect and set a fixed module list. $class = get_class($this); $modules = array();