diff --git a/core/modules/ckeditor/src/Tests/CKEditorTest.php b/core/modules/ckeditor/src/Tests/CKEditorTest.php
index 708f091..300ad27 100644
--- a/core/modules/ckeditor/src/Tests/CKEditorTest.php
+++ b/core/modules/ckeditor/src/Tests/CKEditorTest.php
@@ -266,7 +266,7 @@ function testBuildContentsCssJSSetting() {
 
     // Enable the Bartik theme, which specifies a CKEditor stylesheet.
     \Drupal::service('theme_handler')->install(['bartik']);
-    \Drupal::service('theme_handler')->setDefault('bartik');
+    $this->config('system.theme')->set('default', 'bartik')->save();
     $expected[] = file_url_transform_relative(file_create_url('core/themes/bartik/css/base/elements.css'));
     $expected[] = file_url_transform_relative(file_create_url('core/themes/bartik/css/components/captions.css'));
     $expected[] = file_url_transform_relative(file_create_url('core/themes/bartik/css/components/table.css'));
diff --git a/core/modules/field/src/Tests/DisplayApiTest.php b/core/modules/field/src/Tests/DisplayApiTest.php
index 0ad584d..eff812b 100644
--- a/core/modules/field/src/Tests/DisplayApiTest.php
+++ b/core/modules/field/src/Tests/DisplayApiTest.php
@@ -120,7 +120,7 @@ function testFieldItemListView() {
     $items = $this->entity->get($this->fieldName);
 
     \Drupal::service('theme_handler')->install(['classy']);
-    \Drupal::service('theme_handler')->setDefault('classy');
+    $this->config('system.theme')->set('default', 'classy')->save();
 
     // No display settings: check that default display settings are used.
     $build = $items->view();
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
index 87da3ec..cc41f7d 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
@@ -66,7 +66,7 @@ protected function setUp() {
 
     // Use Classy theme for testing markup output.
     \Drupal::service('theme_handler')->install(['classy']);
-    \Drupal::service('theme_handler')->setDefault('classy');
+    $this->config('system.theme')->set('default', 'classy')->save();
 
     // Grant the 'view test entity' permission.
     $this->installConfig(array('user'));
diff --git a/core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php b/core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php
index 8424866..120d6f0 100644
--- a/core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php
+++ b/core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php
@@ -33,7 +33,7 @@ public function testIntegerFormatter() {
    */
   public function testIntegerFormatterWithSettings() {
     \Drupal::service('theme_handler')->install(['classy']);
-    \Drupal::service('theme_handler')->setDefault('classy');
+    $this->config('system.theme')->set('default', 'classy')->save();
     $this->fieldType = 'integer';
     $formatter = array(
       'type' => 'number_integer',
@@ -76,7 +76,7 @@ public function testFloatFormatter() {
    */
   public function testFloatFormatterWithSettings() {
     \Drupal::service('theme_handler')->install(['classy']);
-    \Drupal::service('theme_handler')->setDefault('classy');
+    $this->config('system.theme')->set('default', 'classy')->save();
     $this->fieldType = 'float';
     $formatter = array(
       'type' => 'number_decimal',
@@ -126,7 +126,7 @@ public function testFloatFormatterWithScale() {
    */
   public function testFloatFormatterWithScaleExercised() {
     \Drupal::service('theme_handler')->install(['classy']);
-    \Drupal::service('theme_handler')->setDefault('classy');
+    $this->config('system.theme')->set('default', 'classy')->save();
     $this->fieldType = 'float';
     $formatter = array(
       'type' => 'number_decimal',
@@ -164,7 +164,7 @@ public function testDecimalFormatter() {
    */
   public function testDecimalFormatterWithSettings() {
     \Drupal::service('theme_handler')->install(['classy']);
-    \Drupal::service('theme_handler')->setDefault('classy');
+    $this->config('system.theme')->set('default', 'classy')->save();
     $this->fieldType = 'decimal';
     $formatter = array(
       'type' => 'number_decimal',
diff --git a/core/modules/rdf/src/Tests/StandardProfileTest.php b/core/modules/rdf/src/Tests/StandardProfileTest.php
index 6ef3b53..57f4c3f 100644
--- a/core/modules/rdf/src/Tests/StandardProfileTest.php
+++ b/core/modules/rdf/src/Tests/StandardProfileTest.php
@@ -109,7 +109,7 @@ protected function setUp() {
 
     // Use Classy theme for testing markup output.
     \Drupal::service('theme_handler')->install(['classy']);
-    \Drupal::service('theme_handler')->setDefault('classy');
+    $this->config('system.theme')->set('default', 'classy')->save();
 
     $this->baseUri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
 
diff --git a/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php b/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php
index 303f583..3139ecc 100644
--- a/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php
+++ b/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php
@@ -52,7 +52,7 @@ public function testCurrentTheme() {
     $this->assertTrue($condition_negated->execute());
 
     // Set the expected theme to be used.
-    \Drupal::service('theme_handler')->setDefault('test_theme');
+    $this->config('system.theme')->set('default', 'test_theme')->save();
     \Drupal::theme()->resetActiveTheme();
 
     $this->assertTrue($condition->execute());
diff --git a/core/modules/system/src/Tests/Render/Element/TableTest.php b/core/modules/system/src/Tests/Render/Element/TableTest.php
index 7e90979..7d94cd9 100644
--- a/core/modules/system/src/Tests/Render/Element/TableTest.php
+++ b/core/modules/system/src/Tests/Render/Element/TableTest.php
@@ -98,7 +98,7 @@ function testThemeTableWithEmptyMessage() {
 
     // Enable the Classy theme.
     \Drupal::service('theme_handler')->install(['classy']);
-    \Drupal::service('theme_handler')->setDefault('classy');
+    $this->config('system.theme')->set('default', 'classy')->save();
 
     $this->render($table);
     $this->removeWhiteSpace();
diff --git a/core/modules/system/src/Tests/Theme/MessageTest.php b/core/modules/system/src/Tests/Theme/MessageTest.php
index 878d5bc..db27d2a 100644
--- a/core/modules/system/src/Tests/Theme/MessageTest.php
+++ b/core/modules/system/src/Tests/Theme/MessageTest.php
@@ -27,7 +27,7 @@ class MessageTest extends KernelTestBase {
   function testMessages() {
     // Enable the Classy theme.
     \Drupal::service('theme_handler')->install(['classy']);
-    \Drupal::service('theme_handler')->setDefault('classy');
+    $this->config('system.theme')->set('default', 'classy')->save();
 
     drupal_set_message('An error occurred', 'error');
     drupal_set_message('But then something nice happened');
diff --git a/core/modules/system/src/Tests/Theme/StableThemeTest.php b/core/modules/system/src/Tests/Theme/StableThemeTest.php
index 0df5c71..1f898ba 100644
--- a/core/modules/system/src/Tests/Theme/StableThemeTest.php
+++ b/core/modules/system/src/Tests/Theme/StableThemeTest.php
@@ -52,7 +52,7 @@ protected function setUp() {
    */
   public function testStableIsDefault() {
     $this->themeHandler->install(['test_stable']);
-    $this->themeHandler->setDefault('test_stable');
+    $this->config('system.theme')->set('default', 'test_stable')->save();
     $theme = $this->themeManager->getActiveTheme();
     /** @var \Drupal\Core\Theme\ActiveTheme $base_theme */
     $base_themes = $theme->getBaseThemes();
@@ -65,7 +65,7 @@ public function testStableIsDefault() {
    */
   public function testWildWest() {
     $this->themeHandler->install(['test_wild_west']);
-    $this->themeHandler->setDefault('test_wild_west');
+    $this->config('system.theme')->set('default', 'test_wild_west')->save();
     $theme = $this->themeManager->getActiveTheme();
     /** @var \Drupal\Core\Theme\ActiveTheme $base_theme */
     $base_themes = $theme->getBaseThemes();
diff --git a/core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php b/core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php
index c220dde..1b330d0 100644
--- a/core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php
+++ b/core/modules/system/src/Tests/Theme/TwigDebugMarkupTest.php
@@ -31,7 +31,7 @@ function testTwigDebugMarkup() {
     $renderer = $this->container->get('renderer');
     $extension = twig_extension();
     \Drupal::service('theme_handler')->install(array('test_theme'));
-    \Drupal::service('theme_handler')->setDefault('test_theme');
+    $this->config('system.theme')->set('default', 'test_theme')->save();
     $this->drupalCreateContentType(array('type' => 'page'));
     // Enable debug, rebuild the service container, and clear all caches.
     $parameters = $this->container->getParameter('twig.config');
diff --git a/core/modules/system/src/Tests/Theme/TwigTransTest.php b/core/modules/system/src/Tests/Theme/TwigTransTest.php
index 9eec247..867c4d5 100644
--- a/core/modules/system/src/Tests/Theme/TwigTransTest.php
+++ b/core/modules/system/src/Tests/Theme/TwigTransTest.php
@@ -54,7 +54,7 @@ protected function setUp() {
 
     // Setup test_theme.
     \Drupal::service('theme_handler')->install(array('test_theme'));
-    \Drupal::service('theme_handler')->setDefault('test_theme');
+    $this->config('system.theme')->set('default', 'test_theme')->save();
 
     // Create and log in as admin.
     $this->adminUser = $this->drupalCreateUser(array(
