diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php
index fbebe944cacfe4c1027f8e04c284a293c0556d5f..6135bf0a1d34eb43e67d3dfb5e110237ef8f24fb 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php
@@ -32,7 +32,7 @@ function testEntityInfoChanges() {
 
     // Change the label of the test entity type and make sure changes appear
     // after flushing caches.
-    variable_set('entity_cache_test_label', 'New label.');
+    state()->set('entity_cache_test.label', 'New label.');
     $info = entity_get_info('entity_cache_test');
     $this->assertEqual($info['label'], 'Entity Cache Test', 'Original label appears in cached entity info.');
     $this->resetAll();
@@ -52,7 +52,7 @@ function testEntityInfoChanges() {
    */
   function testEntityInfoCacheWatchdog() {
     module_enable(array('entity_cache_test'));
-    $info = variable_get('entity_cache_test');
+    $info = state()->get('entity_cache_test');
     $this->assertEqual($info['label'], 'Entity Cache Test', 'Entity info label is correct.');
     $this->assertEqual($info['controller_class'], 'Drupal\Core\Entity\DatabaseStorageController', 'Entity controller class info is correct.');
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
index c7acd4d37b56b9583104129c9606735e99f76e00..d3602292c1332908e87ab161e2c0c67593798c7a 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
@@ -37,7 +37,7 @@ public static function getInfo() {
   function setUp() {
     parent::setUp();
     // Enable translations for the test entity type.
-    variable_set('entity_test_translation', TRUE);
+    state()->set('entity_test.translation', TRUE);
 
     // Create test languages.
     $this->langcodes = array();
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
index b34873a3d6bfdb7c44e88a485028cf55b4f6a757..370622d91483cb97bd8aa358437b3ced508aa2d4 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
@@ -37,7 +37,7 @@ public static function getInfo() {
   function setUp() {
     parent::setUp();
     // Enable translations for the test entity type.
-    variable_set('entity_test_translation', TRUE);
+    state()->set('entity_test.translation', TRUE);
 
     // Create a translatable test field.
     $this->field_name = drupal_strtolower($this->randomName() . '_field_name');
diff --git a/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module b/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module
index 5ae9eccb1e071a7d50ea2e34d39b8ef6e98ebbc7..ed60fe814cf390b18bb2fc880ded8543aa295eb0 100644
--- a/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module
+++ b/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module
@@ -22,6 +22,6 @@ function entity_cache_test_watchdog($log_entry) {
     $info = entity_get_info('entity_cache_test');
     // Store the information in a system variable to analyze it later in the
     // test case.
-    variable_set('entity_cache_test', $info);
+    state()->set('entity_cache_test', $info);
   }
 }
diff --git a/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module b/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module
index 6db46d7953bc435ecf19ee0acad269f5cfbcb518..392a03b1f540daf612d4f899798b012eaa4221e3 100644
--- a/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module
+++ b/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module
@@ -9,5 +9,5 @@
  * Implements hook_entity_info_alter().
  */
 function entity_cache_test_dependency_entity_info_alter(&$info) {
-  $info['entity_cache_test']['label'] = variable_get('entity_cache_test_label', 'Entity Cache Test');
+  $info['entity_cache_test']['label'] = state()->get('entity_cache_test.label') ?: 'Entity Cache Test';
 }
diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module
index 403c1b9ee579ea055998812da20f18c9dc049699..2bb1dde423c5a57908ca9c008b3ca96e33979a58 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.module
+++ b/core/modules/system/tests/modules/entity_test/entity_test.module
@@ -13,7 +13,7 @@
  */
 function entity_test_entity_info_alter(&$info) {
   // Optionally specify a translation handler for testing translations.
-  if (variable_get('entity_test_translation')) {
+  if (state()->get('entity_test.translation')) {
     $info['entity_test']['translation']['entity_test'] = TRUE;
   }
   // Optionally unset the access controller to test the fallback.