protected function TestBase::rebuildContainer

Rebuild drupal_container().

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

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

See also

TestBase::prepareEnvironment()

TestBase::tearDown()

1 call to TestBase::rebuildContainer()
WebTestBase::rebuildContainer in drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
Overrides Drupal\simpletest\TestBase::rebuildContainer().
1 method overrides TestBase::rebuildContainer()
WebTestBase::rebuildContainer in drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
Overrides Drupal\simpletest\TestBase::rebuildContainer().

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php, line 981
Definition of Drupal\simpletest\TestBase.

Class

TestBase
Base class for Drupal tests.

Namespace

Drupal\simpletest

Code

protected function rebuildContainer() {
  $this->kernel = new DrupalKernel('testing', FALSE, drupal_classloader(), FALSE);
  $this->kernel
    ->boot();

  // DrupalKernel replaces the container in drupal_container() with a
  // different object, so we need to replace the instance on this test class.
  $this->container = drupal_container();
}