diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index 54305c0..c0ce1b2 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -13,6 +13,7 @@ use Symfony\Component\DependencyInjection\Reference; use Drupal\Core\Database\Database; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; /** * Base test case class for Drupal unit tests. @@ -183,7 +184,8 @@ public function containerBuild(ContainerBuilder $container) { $definition = $container->getDefinition('path_processor_alias'); $definition->clearTag('path_processor_inbound')->clearTag('path_processor_outbound'); } - + $request = Request::createFromGlobals(); + $this->container->set('request', $request); } /** diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 4780e85..e8da674 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -19,6 +19,7 @@ use Drupal\Core\Language\Language; use ReflectionMethod; use ReflectionObject; +use Symfony\Component\HttpFoundation\Request; /** * Base class for Drupal tests. @@ -922,7 +923,8 @@ protected function prepareEnvironment() { $this->container = new ContainerBuilder(); // @todo Remove this once this class has no calls to t() and format_plural() $this->container->register('string_translation', 'Drupal\Core\StringTranslation\TranslationManager'); - + $request = Request::createFromGlobals(); + $this->container->set('request', $request); \Drupal::setContainer($this->container); // Unset globals. @@ -989,7 +991,10 @@ protected function rebuildContainer() { $this->kernel->boot(); // DrupalKernel replaces the container in drupal_container() with a // different object, so we need to replace the instance on this test class. - $this->container = drupal_container(); + $this->container = \Drupal::getContainer(); + $request = Request::createFromGlobals(); + $request->attributes->set('account', $GLOBALS['user']); + $this->container->set('request', $request); } /**