diff -u b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php --- b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -145,6 +145,11 @@ protected $redirect_count; /** + * The kernel used in this test. + */ + protected $kernel; + + /** * Constructor for Drupal\simpletest\WebTestBase. */ function __construct($test_id = NULL) { @@ -658,10 +663,16 @@ } // Create a new DrupalKernel for testing purposes, now that all required - // modules have been enabled. - $kernel = new DrupalKernel('testing', FALSE); - $kernel->boot(); - $this->kernel = $kernel; + // modules have been enabled. This also stores a new dependency injection + // container in drupal_container(). Drupal\simpletest\TestBase::tearDown() + // restores the original container. + // @see Drupal\Core\DrupalKernel::initializeContainer() + $this->kernel = new DrupalKernel('testing', FALSE); + // While normally the kernel gets booted on demand in + // Symfony\Component\HttpKernel\handle() this kernel is only used to + // create a new dependency injection container and so it needs manual + // booting. + $this->kernel->boot(); // Reset/rebuild all data structures after enabling the modules. $this->resetAll();