Issue #2189411 by alexpott, dawehner, longwave, quietone: Remove an unnecessary container rebuild from FunctionalTestSetupTrait
parent
0e272ad252
commit
db3ad8f8b2
|
@ -377,9 +377,6 @@ trait FunctionalTestSetupTrait {
|
||||||
*/
|
*/
|
||||||
protected function initKernel(Request $request) {
|
protected function initKernel(Request $request) {
|
||||||
$this->kernel = DrupalKernel::createFromRequest($request, $this->classLoader, 'prod', TRUE);
|
$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();
|
$this->kernel->boot();
|
||||||
// Add our request to the stack and route context.
|
// Add our request to the stack and route context.
|
||||||
$request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('<none>'));
|
$request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('<none>'));
|
||||||
|
|
|
@ -44,7 +44,7 @@ trait AssertViewsCacheTagsTrait {
|
||||||
// active for direct rendering of views, just like for actual requests.
|
// active for direct rendering of views, just like for actual requests.
|
||||||
/** @var \Symfony\Component\HttpFoundation\RequestStack $request_stack */
|
/** @var \Symfony\Component\HttpFoundation\RequestStack $request_stack */
|
||||||
$request_stack = \Drupal::service('request_stack');
|
$request_stack = \Drupal::service('request_stack');
|
||||||
$request = new Request();
|
$request = Request::createFromGlobals();
|
||||||
$request->server->set('REQUEST_TIME', REQUEST_TIME);
|
$request->server->set('REQUEST_TIME', REQUEST_TIME);
|
||||||
$view->setRequest($request);
|
$view->setRequest($request);
|
||||||
$request_stack->push($request);
|
$request_stack->push($request);
|
||||||
|
|
|
@ -36,11 +36,8 @@ class InstallerPerformanceTest extends BrowserTestBase {
|
||||||
*/
|
*/
|
||||||
public function testInstaller() {
|
public function testInstaller() {
|
||||||
// Ensures that router is not rebuilt unnecessarily during the install.
|
// Ensures that router is not rebuilt unnecessarily during the install.
|
||||||
// Currently it is built once during the install in install_finished() and
|
// Currently it is built once during the install in install_finished().
|
||||||
// once in \Drupal\Tests\BrowserTestBase::installDrupal() when
|
$this->assertSame(1, \Drupal::service('core.performance.test.recorder')->getCount('event', RoutingEvents::FINISHED));
|
||||||
// \Drupal\Core\Test\FunctionalTestSetupTrait::resetAll() calls
|
|
||||||
// drupal_flush_all_caches()
|
|
||||||
$this->assertSame(2, \Drupal::service('core.performance.test.recorder')->getCount('event', RoutingEvents::FINISHED));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ use Drupal\Component\Serialization\Json;
|
||||||
use Drupal\Core\Database\Database;
|
use Drupal\Core\Database\Database;
|
||||||
use Drupal\Core\Test\FunctionalTestSetupTrait;
|
use Drupal\Core\Test\FunctionalTestSetupTrait;
|
||||||
use Drupal\Core\Test\TestSetupTrait;
|
use Drupal\Core\Test\TestSetupTrait;
|
||||||
|
use Drupal\Core\Url;
|
||||||
use Drupal\Core\Utility\Error;
|
use Drupal\Core\Utility\Error;
|
||||||
use Drupal\FunctionalTests\AssertLegacyTrait;
|
use Drupal\FunctionalTests\AssertLegacyTrait;
|
||||||
use Drupal\Tests\block\Traits\BlockCreationTrait;
|
use Drupal\Tests\block\Traits\BlockCreationTrait;
|
||||||
|
@ -556,11 +557,28 @@ abstract class BrowserTestBase extends TestCase {
|
||||||
$this->prepareSettings();
|
$this->prepareSettings();
|
||||||
$this->doInstall();
|
$this->doInstall();
|
||||||
$this->initSettings();
|
$this->initSettings();
|
||||||
$container = $this->initKernel(\Drupal::request());
|
$this->container = $container = $this->initKernel(\Drupal::request());
|
||||||
$this->initConfig($container);
|
$this->initConfig($container);
|
||||||
$this->installDefaultThemeFromClassProperty($container);
|
$this->installDefaultThemeFromClassProperty($container);
|
||||||
$this->installModulesFromClassProperty($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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue