function FunctionalTestSetupTrait::rebuildContainer
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::rebuildContainer()
- 10 core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::rebuildContainer()
- 8.9.x core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\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()
27 calls to FunctionalTestSetupTrait::rebuildContainer()
- EntityReferenceFieldTranslatedReferenceViewTest::setUp in core/
modules/ field/ tests/ src/ Functional/ EntityReference/ EntityReferenceFieldTranslatedReferenceViewTest.php - ExternalNormalizersTest::testFormatAgnosticNormalizers in core/
modules/ jsonapi/ tests/ src/ Functional/ ExternalNormalizersTest.php - Tests a format-agnostic normalizer.
- FieldImportDeleteUninstallUiTest::testImportDeleteUninstall in core/
modules/ field/ tests/ src/ Functional/ FieldImportDeleteUninstallUiTest.php - Tests deleting field storages and fields as part of config import.
- JsonApiFunctionalMultilingualTest::setUp in core/
modules/ jsonapi/ tests/ src/ Functional/ JsonApiFunctionalMultilingualTest.php - LanguageConfigOverrideImportTest::testConfigOverrideImport in core/
modules/ language/ tests/ src/ Functional/ LanguageConfigOverrideImportTest.php - Tests that language can be enabled and overrides are created during a sync.
File
-
core/
lib/ Drupal/ Core/ Test/ FunctionalTestSetupTrait.php, line 206
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();
// Make sure the URL generator has a request object, otherwise calls to
// $this->drupalGet() will fail.
$this->prepareRequestForGenerator();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.