function FunctionalTestSetupTrait::rebuildContainer
Rebuilds \Drupal::getContainer().
Use this to update the test process's kernel with a new service container. For example, when the list of enabled modules is changed via the internal browser the test process's kernel has a service container with an out of date module list.
@todo Fix https://www.drupal.org/node/2941757 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
TestBase::prepareEnvironment()
TestBase::restoreEnvironment()
File
-
core/
lib/ Drupal/ Core/ Test/ FunctionalTestSetupTrait.php, line 233
Class
- FunctionalTestSetupTrait
- Defines a trait for shared functional test setup functionality.
Namespace
Drupal\Core\TestCode
protected function rebuildContainer() {
// Rebuild the kernel and bring it back to a fully bootstrapped state.
$this->container = $this->kernel
->rebuildContainer();
}