diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php
index cb56a90..dac502f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php
@@ -157,7 +157,8 @@ function testModuleEnableOrder() {
     $this->assertModules(array('forum', 'poll', 'php', 'comment', 'history', 'taxonomy', 'options'), TRUE);
 
     // Check the actual order which is saved by module_test_modules_enabled().
-    $this->assertIdentical(variable_get('test_module_enable_order', array()), $expected_order);
+    $module_order = state()->get('system_test.module_enable_order') ?: array();
+    $this->assertIdentical($module_order, $expected_order);
   }
 
   /**
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php
index f691e7a..e73ace9 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php
@@ -60,7 +60,7 @@ function testEnableDisable() {
 
    // Set a variable so that the hook implementations in system_test.module
    // will display messages via drupal_set_message().
-   variable_set('test_verbose_module_hooks', TRUE);
+   state()->set('system_test.verbose_module_hooks', TRUE);
 
     // Go through each module in the list and try to enable it (unless it was
     // already enabled automatically due to a dependency).
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
index f6e6929..701630e 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
@@ -176,7 +176,8 @@ function testDependencyResolution() {
     // Verify that the original module was installed.
     $this->assertTrue(module_exists('forum'), 'Module installation with unlisted dependencies succeeded.');
     // Finally, verify that the modules were enabled in the correct order.
-    $this->assertEqual(variable_get('test_module_enable_order', array()), array('php', 'poll', 'forum'), 'Modules were enabled in the correct order by module_enable().');
+    $module_order = state()->get('system_test.module_enable_order') ?: array();
+    $this->assertEqual($module_order, array('php', 'poll', 'forum'), 'Modules were enabled in the correct order by module_enable().');
 
     // Now, disable the PHP module. Both forum and poll should be disabled as
     // well, in the correct order.
@@ -239,7 +240,7 @@ function testDependencyResolution() {
     // Verify that the original module was installed.
     $this->assertTrue(module_exists('forum'), 'Module installation with version dependencies succeeded.');
     // Finally, verify that the modules were enabled in the correct order.
-    $enable_order = variable_get('test_module_enable_order', array());
+    $enable_order = state()->get('system_test.module_enable_order') ?: array();
     $php_position = array_search('php', $enable_order);
     $poll_position = array_search('poll', $enable_order);
     $forum_position = array_search('forum', $enable_order);
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php b/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php
index bab510b..8b98ecf 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php
@@ -40,7 +40,7 @@ function setUp() {
     // Configure 'node' as front page.
     config('system.site')->set('page.front', 'node')->save();
     // Enable front page logging in system_test.module.
-    variable_set('front_page_output', 1);
+    state()->set('system_test.front_page_output', 1);
   }
 
   /**
diff --git a/core/modules/system/tests/modules/image_test/image_test.module b/core/modules/system/tests/modules/image_test/image_test.module
index de640f0..fb6b720 100644
--- a/core/modules/system/tests/modules/image_test/image_test.module
+++ b/core/modules/system/tests/modules/image_test/image_test.module
@@ -37,7 +37,7 @@ function image_test_reset() {
     'crop' => array(),
     'desaturate' => array(),
   );
-  variable_set('image_test_results', $results);
+  state()->set('image_test.results', $results);
 }
 
 /**
@@ -50,7 +50,7 @@ function image_test_reset() {
  *   passed to each call.
  */
 function image_test_get_all_calls() {
-  return variable_get('image_test_results', array());
+  return state()->get('image_test.results') ?: array();
 }
 
 /**
@@ -66,9 +66,9 @@ function image_test_get_all_calls() {
  * @see image_test_reset()
  */
 function _image_test_log_call($op, $args) {
-  $results = variable_get('image_test_results', array());
+  $results = state()->get('image_test.results') ?: array();
   $results[$op][] = $args;
-  variable_set('image_test_results', $results);
+  state()->set('image_test.results', $results);
 }
 
 /**
diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module
index 69e5bfe..e379c3e 100644
--- a/core/modules/system/tests/modules/module_test/module_test.module
+++ b/core/modules/system/tests/modules/module_test/module_test.module
@@ -155,7 +155,7 @@ function module_test_class_loading() {
 function module_test_modules_enabled($modules) {
   // Record the ordered list of modules that were passed in to this hook so we
   // can check that the modules were enabled in the correct sequence.
-  variable_set('test_module_enable_order', $modules);
+  state()->set('system_test.module_enable_order', $modules);
 }
 
 /**
diff --git a/core/modules/system/tests/modules/path_test/path_test.module b/core/modules/system/tests/modules/path_test/path_test.module
index 0111675..dd70498 100644
--- a/core/modules/system/tests/modules/path_test/path_test.module
+++ b/core/modules/system/tests/modules/path_test/path_test.module
@@ -9,14 +9,14 @@
  * Resets the path test results.
  */
 function path_test_reset() {
-  variable_set('path_test_results', array());
+  state()->set('path_test.results', array());
 }
 
 /**
  * Implements hook_path_update().
  */
 function path_test_path_update($path) {
-  $results = variable_get('path_test_results', array());
+  $results = state()->get('path_test.results') ?: array();
   $results['hook_path_update'] = $path;
-  variable_set('path_test_results', $results);
+  state()->set('path_test.results', $results);
 }
diff --git a/core/modules/system/tests/modules/system_test/system_test.module b/core/modules/system/tests/modules/system_test/system_test.module
index e833ba7..ee67964 100644
--- a/core/modules/system/tests/modules/system_test/system_test.module
+++ b/core/modules/system/tests/modules/system_test/system_test.module
@@ -177,7 +177,7 @@ function system_test_redirect_invalid_scheme() {
  * Implements hook_modules_installed().
  */
 function system_test_modules_installed($modules) {
-  if (variable_get('test_verbose_module_hooks')) {
+  if (state()->get('system_test.verbose_module_hooks')) {
     foreach ($modules as $module) {
       drupal_set_message(t('hook_modules_installed fired for @module', array('@module' => $module)));
     }
@@ -188,7 +188,7 @@ function system_test_modules_installed($modules) {
  * Implements hook_modules_enabled().
  */
 function system_test_modules_enabled($modules) {
-  if (variable_get('test_verbose_module_hooks')) {
+  if (state()->get('system_test.verbose_module_hooks')) {
     foreach ($modules as $module) {
       drupal_set_message(t('hook_modules_enabled fired for @module', array('@module' => $module)));
     }
@@ -199,7 +199,7 @@ function system_test_modules_enabled($modules) {
  * Implements hook_modules_disabled().
  */
 function system_test_modules_disabled($modules) {
-  if (variable_get('test_verbose_module_hooks')) {
+  if (state()->get('system_test.verbose_module_hooks')) {
     foreach ($modules as $module) {
       drupal_set_message(t('hook_modules_disabled fired for @module', array('@module' => $module)));
     }
@@ -210,7 +210,7 @@ function system_test_modules_disabled($modules) {
  * Implements hook_modules_uninstalled().
  */
 function system_test_modules_uninstalled($modules) {
-  if (variable_get('test_verbose_module_hooks')) {
+  if (state()->get('system_test.verbose_module_hooks')) {
     foreach ($modules as $module) {
       drupal_set_message(t('hook_modules_uninstalled fired for @module', array('@module' => $module)));
     }
@@ -229,7 +229,8 @@ function system_test_boot() {
  */
 function system_test_init() {
   // Used by FrontPageTestCase to get the results of drupal_is_front_page().
-  if (variable_get('front_page_output', 0) && drupal_is_front_page()) {
+  $frontpage = state()->get('system_test.front_page_output') ?: 0;
+  if ($frontpage && drupal_is_front_page()) {
     drupal_set_message(t('On front page.'));
   }
 }
