Unverified Commit db3ad8f8 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2189411 by alexpott, dawehner, longwave, quietone: Remove an...

Issue #2189411 by alexpott, dawehner, longwave, quietone: Remove an unnecessary container rebuild from FunctionalTestSetupTrait
parent 0e272ad2
Loading
Loading
Loading
Loading
+0 −3
Changes for core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php: 0 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -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>'));
+1 −1
Changes for core/modules/views/src/Tests/AssertViewsCacheTagsTrait.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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);
+2 −5
Changes for core/tests/Drupal/FunctionalTests/Installer/InstallerPerformanceTest.php: 2 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -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));
  }

}
+20 −2
Changes for core/tests/Drupal/Tests/BrowserTestBase.php: 20 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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();
  }

  /**