diff -u b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php --- b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -1168,7 +1168,7 @@ // which means they may need to access its filesystem and database. drupal_static_reset(); - if ($this->container->has('state') && $state = $this->container->get('state')) { + if ($this->container && $this->container->has('state') && $state = $this->container->get('state')) { $captured_emails = $state->get('system.test_mail_collector') ?: array(); $emailCount = count($captured_emails); if ($emailCount) { @@ -1247,7 +1247,7 @@ $callbacks = $this->originalShutdownCallbacks; // Restore original user session. - $this->container->set('current_user', $this->originalUser); + \Drupal::getContainer()->set('current_user', $this->originalUser); drupal_save_session(TRUE); } only in patch2: unchanged: --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -131,12 +131,12 @@ protected function setUp() { $this->prepareConfigDirectories(); // Build a minimal, partially mocked environment for unit tests. - $this->containerBuild(\Drupal::getContainer()); + $this->containerBuild(new ContainerBuilder()); // Make sure it survives kernel rebuilds. $GLOBALS['conf']['container_service_providers']['TestServiceProvider'] = 'Drupal\simpletest\TestServiceProvider'; - \Drupal::state()->set('system.module.files', $this->moduleFiles); - \Drupal::state()->set('system.theme.files', $this->themeFiles); + $this->container->get('state')->set('system.module.files', $this->moduleFiles); + $this->container->get('state')->set('system.theme.files', $this->themeFiles); // Bootstrap the kernel. // No need to dump it; this test runs in-memory. only in patch2: unchanged: --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/MissingDependentModuleUnitTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/MissingDependentModuleUnitTest.php @@ -26,6 +26,6 @@ public static function getInfo() { * Ensure that this test will not be loaded despite its dependency. */ function testFail() { - $this->fail(t('Running test with missing required module.')); + $this->fail('Running test with missing required module.'); } }