You are here

protected function FunctionalTestSetupTrait::initKernel in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::initKernel()
  2. 10 core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::initKernel()

Initializes the kernel after installation.

Parameters

\Symfony\Component\HttpFoundation\Request $request: Request object.

Return value

\Symfony\Component\DependencyInjection\ContainerInterface The container.

5 calls to FunctionalTestSetupTrait::initKernel()
BrowserTestBase::installDrupal in core/tests/Drupal/Tests/BrowserTestBase.php
Installs Drupal into the Simpletest site.
TestSiteInstallCommand::installDrupal in core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php
Installs Drupal into the test site.
UpdatePathTestBase::installDrupal in core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php
Installs Drupal into the Simpletest site.
UpdatePathTestBase::setUp in core/modules/system/src/Tests/Update/UpdatePathTestBase.php
Overrides WebTestBase::setUp() for update testing.
WebTestBase::setUp in core/modules/simpletest/src/WebTestBase.php
Sets up a Drupal site for running functional and integration tests.

File

core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php, line 390

Class

FunctionalTestSetupTrait
Defines a trait for shared functional test setup functionality.

Namespace

Drupal\Core\Test

Code

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>'));
  $request->attributes
    ->set(RouteObjectInterface::ROUTE_NAME, '<none>');
  $this->kernel
    ->preHandle($request);
  return $this->kernel
    ->getContainer();
}