diff --git a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php index c797f4cf756116d3eea8f9e735802b7b5e138a12..63bf5c75fa838d663876ff8d1de3c1fd3f4dafdf 100644 --- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php +++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php @@ -377,9 +377,6 @@ protected function initUserSession() { */ protected function initKernel(Request $request) { $this->kernel = DrupalKernel::createFromRequest($request, $this->classLoader, 'prod', TRUE); - // Force the container to be built from scratch instead of loaded from the - // disk. This forces us to not accidentally load the parent site. - $this->kernel->invalidateContainer(); $this->kernel->boot(); // Add our request to the stack and route context. $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('<none>')); diff --git a/core/modules/views/src/Tests/AssertViewsCacheTagsTrait.php b/core/modules/views/src/Tests/AssertViewsCacheTagsTrait.php index 048c58e811ae1a187dd2bdcbed5068ca7e804e3b..79b38df96c51e9edb11a9f7b691b09aaf90e3515 100644 --- a/core/modules/views/src/Tests/AssertViewsCacheTagsTrait.php +++ b/core/modules/views/src/Tests/AssertViewsCacheTagsTrait.php @@ -44,7 +44,7 @@ protected function assertViewsCacheTags(ViewExecutable $view, $expected_results_ // active for direct rendering of views, just like for actual requests. /** @var \Symfony\Component\HttpFoundation\RequestStack $request_stack */ $request_stack = \Drupal::service('request_stack'); - $request = new Request(); + $request = Request::createFromGlobals(); $request->server->set('REQUEST_TIME', REQUEST_TIME); $view->setRequest($request); $request_stack->push($request); diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerPerformanceTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerPerformanceTest.php index 6ea5e70062298926315adc6fe50ad254925e6952..22541572baa6fb2bc06b85418263156fee8956d9 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerPerformanceTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerPerformanceTest.php @@ -36,11 +36,8 @@ protected function prepareSettings() { */ public function testInstaller() { // Ensures that router is not rebuilt unnecessarily during the install. - // Currently it is built once during the install in install_finished() and - // once in \Drupal\Tests\BrowserTestBase::installDrupal() when - // \Drupal\Core\Test\FunctionalTestSetupTrait::resetAll() calls - // drupal_flush_all_caches() - $this->assertSame(2, \Drupal::service('core.performance.test.recorder')->getCount('event', RoutingEvents::FINISHED)); + // Currently it is built once during the install in install_finished(). + $this->assertSame(1, \Drupal::service('core.performance.test.recorder')->getCount('event', RoutingEvents::FINISHED)); } } diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index d7a4bd9d34445e2c2ff431a16070073cd02acee3..24ce2fb7bb03622d3f2a7ae0a2832832e6538bd8 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -12,6 +12,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\Test\FunctionalTestSetupTrait; use Drupal\Core\Test\TestSetupTrait; +use Drupal\Core\Url; use Drupal\Core\Utility\Error; use Drupal\FunctionalTests\AssertLegacyTrait; use Drupal\Tests\block\Traits\BlockCreationTrait; @@ -556,11 +557,28 @@ public function installDrupal() { $this->prepareSettings(); $this->doInstall(); $this->initSettings(); - $container = $this->initKernel(\Drupal::request()); + $this->container = $container = $this->initKernel(\Drupal::request()); $this->initConfig($container); $this->installDefaultThemeFromClassProperty($container); $this->installModulesFromClassProperty($container); - $this->rebuildAll(); + + // Clear the static cache so that subsequent cache invalidations will work + // as expected. + $this->container->get('cache_tags.invalidator')->resetChecksums(); + + // Set the dummy query string added to all CSS and JavaScript files. + // @todo Remove in https://www.drupal.org/project/drupal/issues/3207893. + _drupal_flush_css_js(); + + // Generate a route to prime the url generator with the correct base url. + // @todo Remove in https://www.drupal.org/project/drupal/issues/3207896. + Url::fromRoute('<front>')->setAbsolute()->toString(); + + // Explicitly call register() again on the container registered in \Drupal. + // @todo This should already be called through + // DrupalKernel::prepareLegacyRequest() -> DrupalKernel::boot() but that + // appears to be calling a different container. + $this->container->get('stream_wrapper_manager')->register(); } /**