diff -u b/core/modules/language/src/Tests/EntityUrlLanguageTest.php b/core/modules/language/src/Tests/EntityUrlLanguageTest.php --- b/core/modules/language/src/Tests/EntityUrlLanguageTest.php +++ b/core/modules/language/src/Tests/EntityUrlLanguageTest.php @@ -12,6 +12,9 @@ use Drupal\language\Entity\ConfigurableLanguage; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Route; /** * Tests the language of entity URLs. @@ -49,8 +52,7 @@ $config = $this->config('language.negotiation'); $config->set('url.prefixes', ['en' => 'en', 'es' => 'es', 'fr' => 'fr']) ->save(); - - $this->rebuildContainer(); + $this->kernel->rebuildContainer(); $this->createTranslatableEntity(); } @@ -83,7 +85,7 @@ // In order to reflect the changes for a multilingual site in the container // we have to rebuild it. - $this->rebuildContainer(); + $this->kernel->rebuildContainer(); // Without being on an content entity route the default entity url tests // should still pass. @@ -111,7 +113,7 @@ // In order to reflect the changes for a multilingual site in the container // we have to rebuild it. - $this->rebuildContainer(); + $this->kernel->rebuildContainer(); // The default entity url tests should pass again with the current // configuration. @@ -130,2 +132,18 @@ + /** + * Sets the current request to a specific path with the corresponding route. + * + * @param string $path + * The path for which the current request should be created. + * @param string $route_name + * The route name for which the route object for the request should be + * created. + */ + protected function setCurrentRequestForRoute($path, $route_name) { + $request = Request::create($path); + $request->attributes->set(RouteObjectInterface::ROUTE_NAME, $route_name); + $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route($path)); + $this->container->get('request_stack')->push($request); + } + } diff -u b/core/modules/language/src/Tests/LanguageNegotiationContentEntityTest.php b/core/modules/language/src/Tests/LanguageNegotiationContentEntityTest.php --- b/core/modules/language/src/Tests/LanguageNegotiationContentEntityTest.php +++ b/core/modules/language/src/Tests/LanguageNegotiationContentEntityTest.php @@ -14,6 +14,9 @@ use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl; use Drupal\simpletest\WebTestBase; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Route; /** * Tests language negotiation with the language negotiator content entity. @@ -161,2 +164,18 @@ } + + /** + * Sets the current request to a specific path with the corresponding route. + * + * @param string $path + * The path for which the current request should be created. + * @param string $route_name + * The route name for which the route object for the request should be + * created. + */ + protected function setCurrentRequestForRoute($path, $route_name) { + $request = Request::create($path); + $request->attributes->set(RouteObjectInterface::ROUTE_NAME, $route_name); + $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route($path)); + $this->container->get('request_stack')->push($request); + } } reverted: --- b/core/modules/simpletest/src/TestBase.php +++ a/core/modules/simpletest/src/TestBase.php @@ -19,9 +19,6 @@ use Drupal\Core\Site\Settings; use Drupal\Core\StreamWrapper\PublicStream; use Drupal\Core\Utility\Error; -use Symfony\Cmf\Component\Routing\RouteObjectInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Route; /** * Base class for Drupal tests. @@ -1589,28 +1586,4 @@ return $this->tempFilesDirectory; } - /** - * Force a container rebuild. - */ - protected function rebuildContainer() { - // Rebuild the kernel and bring it back to a fully bootstrapped state. - $this->container = $this->kernel->rebuildContainer(); - } - - /** - * Sets the current request to a specific path with the corresponding route. - * - * @param string $path - * The path for which the current request should be created. - * @param string $route_name - * The route name for which the route object for the request should be - * created. - */ - protected function setCurrentRequestForRoute($path, $route_name) { - $request = Request::create($path); - $request->attributes->set(RouteObjectInterface::ROUTE_NAME, $route_name); - $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route($path)); - \Drupal::requestStack()->push($request); - } - } reverted: --- b/core/modules/simpletest/src/WebTestBase.php +++ a/core/modules/simpletest/src/WebTestBase.php @@ -1173,7 +1173,8 @@ * enabled modules to be immediately available in the same request. */ protected function rebuildContainer() { + // Rebuild the kernel and bring it back to a fully bootstrapped state. + $this->container = $this->kernel->rebuildContainer(); - parent::rebuildContainer(); // Make sure the url generator has a request object, otherwise calls to // $this->drupalGet() will fail.