You are here

protected function BrowserTestBase::rebuildContainer in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/BrowserTestBase.php \Drupal\simpletest\BrowserTestBase::rebuildContainer()

Rebuilds \Drupal::getContainer().

Use this to build a new kernel and service container. For example, when the list of enabled modules is changed via the Mink controlled browser, in which case the test process still contains an old kernel and service container with an old module list.

@todo Fix https://www.drupal.org/node/2021959 so that module enable/disable changes are immediately reflected in \Drupal::getContainer(). Until then, tests can invoke this workaround when requiring services from newly enabled modules to be immediately available in the same request.

See also

BrowserTestBase::prepareEnvironment()

BrowserTestBase::restoreEnvironment()

1 call to BrowserTestBase::rebuildContainer()
BrowserTestBase::installDrupal in core/modules/simpletest/src/BrowserTestBase.php
Installs Drupal into the Simpletest site.

File

core/modules/simpletest/src/BrowserTestBase.php, line 1211
Contains \Drupal\simpletest\BrowserTestBase.

Class

BrowserTestBase
Provides a test case for functional Drupal tests.

Namespace

Drupal\simpletest

Code

protected function rebuildContainer() {

  // Rebuild the kernel and bring it back to a fully bootstrapped state.
  $this->container = $this->kernel
    ->rebuildContainer();

  // Make sure the url generator has a request object, otherwise calls to
  // $this->drupalGet() will fail.
  $this
    ->prepareRequestForGenerator();
}