diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 5ff660c..ab560b2 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -1095,12 +1095,6 @@ protected function rebuildContainer() { // Rebuild the kernel and bring it back to a fully bootstrapped state. $this->container = $this->kernel->rebuildContainer(); - // 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(); @@ -2697,7 +2691,13 @@ protected function prepareRequestForGenerator($clean_urls = TRUE, $override_serv $request = Request::create($request_path, 'GET', array(), array(), array(), $server); $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); + return $request; } }