diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 340b555..7e7ef1e 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -866,7 +866,26 @@ protected function setUp() { // Not using File API; a potential error must trigger a PHP warning. chmod(DRUPAL_ROOT . '/' . $this->siteDirectory, 0777); - $this->rebuildContainer(); + // Replace the installer-kernel with a production kernel. Allow dumping, but + // do not allow loading of the container. + $this->kernel = new DrupalKernel('prod', drupal_classloader(), TRUE, FALSE); + $this->kernel->boot(); + $this->container = \Drupal::getContainer(); + + // Prepare the services depending on the request. + $request = Request::createFromGlobals(); + $this->container->set('request', $request); + $this->container->get('request_stack')->push($request); + + // The request context is normally set by the router_listener from within + // its KernelEvents::REQUEST listener. In the simpletest parent site this + // event is not fired, therefore it is necessary to updated the request + // context manually here. + $this->container->get('router.request_context')->fromRequest($request); + + // Make sure the url generator has a request object, otherwise calls to + // $this->drupalGet() will fail. + $request = $this->prepareRequestForGenerator(); // Manually create and configure private and temporary files directories. // While these could be preset/enforced in settings.php like the public @@ -1085,39 +1104,6 @@ protected function writeCustomTranslations() { * enabled modules to be immediately available in the same request. */ protected function rebuildContainer($environment = 'prod') { - // Preserve the request object after the container rebuild. - $request = \Drupal::request(); - // When called from InstallerTestBase, the current container is the minimal - // container from TestBase::prepareEnvironment(), which does not contain a - // request stack. - if (\Drupal::getContainer()->initialized('request_stack')) { - $request_stack = \Drupal::service('request_stack'); - } - - $this->kernel = new DrupalKernel($environment, drupal_classloader(), FALSE); - $this->kernel->boot(); - // DrupalKernel replaces the container in \Drupal::getContainer() with a - // different object, so we need to replace the instance on this test class. - $this->container = \Drupal::getContainer(); - // The current user is set in TestBase::prepareEnvironment(). - $this->container->set('request', $request); - if (isset($request_stack)) { - $this->container->set('request_stack', $request_stack); - } - else { - $this->container->get('request_stack')->push($request); - } - $this->container->get('current_user')->setAccount(\Drupal::currentUser()); - - // The request context is normally set by the router_listener from within - // its KernelEvents::REQUEST listener. In the simpletest parent site this - // event is not fired, therefore it is necessary to updated the request - // context manually here. - $this->container->get('router.request_context')->fromRequest($request); - - // Make sure the url generator has a request object, otherwise calls to - // $this->drupalGet() will fail. - $this->prepareRequestForGenerator(); } /**