diff --git a/core/modules/editor/tests/modules/editor_test/editor_test.module b/core/modules/editor/tests/modules/editor_test/editor_test.module
index 63608e1e703a3264605d36562f77d9d12178f1f3..28f9e77bc018d28cd1278b68f5bb18b285c9758c 100644
--- a/core/modules/editor/tests/modules/editor_test/editor_test.module
+++ b/core/modules/editor/tests/modules/editor_test/editor_test.module
@@ -63,7 +63,7 @@ function editor_test_editor_js_settings_alter(&$settings) {
  */
 function editor_test_editor_xss_filter_alter(&$editor_xss_filter_class, FilterFormatInterface $format, ?FilterFormatInterface $original_format = NULL) {
   // Allow tests to enable or disable this alter hook.
-  if (!\Drupal::state()->get('editor_test_editor_xss_filter_alter_enabled', FALSE)) {
+  if (!\Drupal::keyValue('editor_test')->get('editor_xss_filter_alter_enabled', FALSE)) {
     return;
   }
 
diff --git a/core/modules/editor/tests/src/Functional/EditorSecurityTest.php b/core/modules/editor/tests/src/Functional/EditorSecurityTest.php
index 26d4bdaeb4cc03dd3ee6d820f28828b5cd8f1cd7..d344fed3a43ef3dfc9df217f425a4b63c8785a7f 100644
--- a/core/modules/editor/tests/src/Functional/EditorSecurityTest.php
+++ b/core/modules/editor/tests/src/Functional/EditorSecurityTest.php
@@ -445,9 +445,9 @@ public function testEditorXssFilterOverride(): void {
     $this->drupalGet('node/2/edit');
     $this->assertSession()->fieldValueEquals('edit-body-0-value', self::$sampleContentSecured);
 
-    // Enable editor_test.module's hook_editor_xss_filter_alter() implementation
+    // Enable editor_test's hook_editor_xss_filter_alter() implementation
     // to alter the text editor XSS filter class being used.
-    \Drupal::state()->set('editor_test_editor_xss_filter_alter_enabled', TRUE);
+    \Drupal::keyValue('editor_test')->set('editor_xss_filter_alter_enabled', TRUE);
 
     // First: the Insecure text editor XSS filter.
     $this->drupalGet('node/2/edit');