You are here

protected function WebTestBase::rebuildContainer in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/simpletest/src/WebTestBase.php \Drupal\simpletest\WebTestBase::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/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

TestBase::prepareEnvironment()

TestBase::restoreEnvironment()

60 calls to WebTestBase::rebuildContainer()
AjaxFormCacheTest::testBlockForms in core/modules/system/src/Tests/Ajax/AjaxFormCacheTest.php
Tests AJAX forms in blocks.
BlockInstallTest::testCacheTagInvalidationUponInstallation in core/modules/block/src/Tests/BlockInstallTest.php
CommentFieldsTest::testCommentInstallAfterContentModule in core/modules/comment/src/Tests/CommentFieldsTest.php
Tests that comment module works when installed after a content module.
ConfigImportAllTest::testInstallUninstall in core/modules/config/src/Tests/ConfigImportAllTest.php
Tests that a fixed set of modules can be installed and uninstalled.
ConfigImportInstallProfileTest::testInstallProfileValidation in core/modules/config/src/Tests/ConfigImportInstallProfileTest.php
Tests config importer cannot uninstall install profiles.

... See full list

File

core/modules/simpletest/src/WebTestBase.php, line 1173
Contains \Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical 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();
}