From 8abf81e7e9daa15bec115e1cb635e2a4aed229dd Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Fri, 16 Jul 2021 08:47:59 +0100
Subject: [PATCH] Issue #3223267 by alexpott, daffie: Remove some calls to
 drupal_flush_all_caches() in tests

---
 .../ckeditor/tests/src/Functional/CKEditorLoadingTest.php       | 2 +-
 .../tests/src/FunctionalJavascript/CKEditorIntegrationTest.php  | 2 +-
 .../jsonapi/tests/src/Functional/InternalEntitiesTest.php       | 2 +-
 .../jsonapi/tests/src/Functional/JsonApiFunctionalTestBase.php  | 2 +-
 .../tests/src/Kernel/LanguageConfigFactoryOverrideTest.php      | 2 +-
 .../src/Functional/LocaleTranslatedSchemaDefinitionTest.php     | 2 +-
 .../modules/system/tests/src/Functional/Theme/ThemeInfoTest.php | 2 +-
 core/tests/Drupal/KernelTests/Core/Entity/EntityKeysTest.php    | 2 +-
 .../Core/TypedData/RecursiveContextualValidatorTest.php         | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php
index cf34e427d8cf..fec5083a088b 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 3eddae8b76be..90d60e40eb58 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 90d9dd5d2d47..032c49698e53 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 7a123e728ca5..832278be1b5b 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 722fcbc8addc..7079918e7bd2 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 434511da72ad..c7c7b94909bf 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 eab06c75f619..64b9b87bde75 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 79a06c936ffd..18eb76267d3b 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 d43cd7d7a1a0..6e5269e7dbda 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',
-- 
GitLab