diff --git a/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php
index cf34e427d8cf16e1834d2ed34041fe885d28ec4f..fec5083a088b604e266934ce048f26c48cd1cb7e 100644
--- a/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php
+++ b/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php
@@ -173,7 +173,7 @@ public function testLoading() {
     $this->assertSame($expected, \Drupal::state()->get('system.css_js_query_string'), "CKEditor scripts cache-busting string is correct before flushing all caches.");
     // Flush all caches then make sure that $settings['ckeditor']['timestamp']
     // still matches.
-    drupal_flush_all_caches();
+    $this->resetAll();
     $this->assertSame($expected, \Drupal::state()->get('system.css_js_query_string'), "CKEditor scripts cache-busting string is correct after flushing all caches.");
   }
 
diff --git a/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
index 3eddae8b76be7ad7eca8ba8a5f032aacf378447a..90d60e40eb58dd53af85544d34d07ca62882f369 100644
--- a/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
+++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
@@ -218,7 +218,7 @@ public function testOffCanvasStyles() {
     $old_keys = $this->getSession()->evaluateScript($get_cache_keys);
     // Flush the caches to ensure the new timestamp is altered into the
     // drupal.ckeditor library's javascript settings.
-    drupal_flush_all_caches();
+    $this->resetAll();
     // Normally flushing caches regenerates the cache busting query string, but
     // as it's based on the request time, it won't change within this test so
     // explicitly set it.
diff --git a/core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php b/core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php
index 90d9dd5d2d47907c8810a33ab11ea8e0d77b8797..032c49698e53a75b98520d41d8ce900600e79df6 100644
--- a/core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php
@@ -83,7 +83,7 @@ public function setUp(): void {
       'field_internal' => $this->internalEntity->id(),
     ]);
     $this->referencingEntity->save();
-    drupal_flush_all_caches();
+    \Drupal::service('router.builder')->rebuild();
   }
 
   /**
diff --git a/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTestBase.php b/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTestBase.php
index 7a123e728ca54d2371f0fbb84a44eea7060490f2..832278be1b5b244720d4fd0d01b3ddee84ec52f3 100644
--- a/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTestBase.php
+++ b/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTestBase.php
@@ -191,7 +191,7 @@ protected function setUp() {
       'administer taxonomy',
     ]);
 
-    drupal_flush_all_caches();
+    \Drupal::service('router.builder')->rebuild();
   }
 
   /**
diff --git a/core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php b/core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php
index 722fcbc8addc6debd9c7acd48c72b43809dcbe01..7079918e7bd24ce6ddc425479963c79dc5d88073 100644
--- a/core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php
+++ b/core/modules/language/tests/src/Kernel/LanguageConfigFactoryOverrideTest.php
@@ -34,7 +34,7 @@ public function testLanguageConfigFactoryOverride() {
 
     // Invalidate the container.
     $this->config('system.site')->set('default_langcode', 'de')->save();
-    drupal_flush_all_caches();
+    $this->container->get('kernel')->rebuildContainer();
 
     $config_factory_override = \Drupal::service('language.config_factory_override');
     $this->assertEquals('de', $config_factory_override->getLanguage()->getId());
diff --git a/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php b/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php
index 434511da72ad78cff324660afcff9046f3ecb97b..c7c7b94909bf5bd8f778fc61ef85f03f97c156f4 100644
--- a/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php
+++ b/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php
@@ -37,7 +37,7 @@ protected function setUp(): void {
 
     // Clear all caches so that the base field definition, its cache in the
     // entity field manager, the t() cache, etc. are all cleared.
-    drupal_flush_all_caches();
+    $this->resetAll();
   }
 
   /**
diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php
index eab06c75f6191430a7ae14587e9304adce80298e..64b9b87bde7521f402e7fc024803311cc41d2776 100644
--- a/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php
+++ b/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php
@@ -99,7 +99,7 @@ public function testChanges() {
 
     // @see theme_test_system_info_alter()
     $this->state->set('theme_test.modify_info_files', TRUE);
-    drupal_flush_all_caches();
+    $this->resetAll();
     $active_theme = $this->themeManager->getActiveTheme();
     $this->assertEquals(['classy/base', 'classy/messages', 'core/normalize', 'test_theme/global-styling', 'core/backbone'], $active_theme->getLibraries());
   }
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityKeysTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityKeysTest.php
index 79a06c936ffd43ca627069b64512bec38d56d50e..18eb76267d3b9cd33cd4c85283e82a38a7d5eb39 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityKeysTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityKeysTest.php
@@ -25,7 +25,7 @@ public function testMultipleKeysCache($translatable) {
       'key_1' => 'test_field',
       'key_2' => 'test_field',
     ]);
-    drupal_flush_all_caches();
+
     $this->installEntitySchema('entity_test');
 
     $entity = EntityTest::create([]);
diff --git a/core/tests/Drupal/KernelTests/Core/TypedData/RecursiveContextualValidatorTest.php b/core/tests/Drupal/KernelTests/Core/TypedData/RecursiveContextualValidatorTest.php
index d43cd7d7a1a08188a41d98766fedbdc44669de9d..6e5269e7dbda286661b82fe86cd7a02eec4cf4b6 100644
--- a/core/tests/Drupal/KernelTests/Core/TypedData/RecursiveContextualValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/TypedData/RecursiveContextualValidatorTest.php
@@ -58,7 +58,7 @@ public function testRecursiveViolationPropagation() {
       ->setLabel('Required string')
       ->setRequired(TRUE);
     $this->container->get('state')->set('entity_test.additional_base_field_definitions', $definitions);
-    drupal_flush_all_caches();
+
     $this->installEntitySchema('entity_test');
     $child = EntityTest::create([
       'name' => 'test2',