From 2a54447213baee8023f8dde1623f03095168dfeb Mon Sep 17 00:00:00 2001 From: catch <6915-catch@users.noreply.drupalcode.org> Date: Fri, 10 Jan 2025 14:22:22 +0000 Subject: [PATCH] Issue #3496438 by spokje, larowlan: [random test failure] LanguageNegotiationInfoTest::testInfoAlterations (cherry picked from commit ab7f10d5d74e7828d66898279ca6d935ca2246c8) --- .../src/Functional/CommentLanguageTest.php | 2 +- .../tests/language_test/language_test.module | 6 ++--- .../LanguageNegotiationInfoTest.php | 24 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/core/modules/comment/tests/src/Functional/CommentLanguageTest.php b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php index 213e4e042111..5da8ea42e10e 100644 --- a/core/modules/comment/tests/src/Functional/CommentLanguageTest.php +++ b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php @@ -73,7 +73,7 @@ protected function setUp(): void { $this->submitForm($edit, 'Save'); // Enable content language negotiation UI. - \Drupal::state()->set('language_test.content_language_type', TRUE); + \Drupal::keyValue('language_test')->set('content_language_type', TRUE); // Set interface language detection to user and content language detection // to URL. Disable inheritance from interface language to ensure content diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module index dc5e63a4e619..3ef6906d9876 100644 --- a/core/modules/language/tests/language_test/language_test.module +++ b/core/modules/language/tests/language_test/language_test.module @@ -23,7 +23,7 @@ function language_test_page_top() { * Implements hook_language_types_info(). */ function language_test_language_types_info() { - if (\Drupal::state()->get('language_test.language_types')) { + if (\Drupal::keyValue('language_test')->get('language_types')) { return [ 'test_language_type' => [ 'name' => t('Test'), @@ -41,7 +41,7 @@ function language_test_language_types_info() { * Implements hook_language_types_info_alter(). */ function language_test_language_types_info_alter(array &$language_types) { - if (\Drupal::state()->get('language_test.content_language_type')) { + if (\Drupal::keyValue('language_test')->get('content_language_type')) { $language_types[LanguageInterface::TYPE_CONTENT]['locked'] = FALSE; unset($language_types[LanguageInterface::TYPE_CONTENT]['fixed']); // By default languages are not configurable. Make @@ -59,7 +59,7 @@ function language_test_language_types_info_alter(array &$language_types) { * Implements hook_language_negotiation_info_alter(). */ function language_test_language_negotiation_info_alter(array &$negotiation_info) { - if (\Drupal::state()->get('language_test.language_negotiation_info_alter')) { + if (\Drupal::keyValue('language_test')->get('language_negotiation_info_alter')) { unset($negotiation_info[LanguageNegotiationUI::METHOD_ID]); } } diff --git a/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php b/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php index de45e2c68d82..6228a9b8562a 100644 --- a/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php +++ b/core/modules/language/tests/src/Functional/LanguageNegotiationInfoTest.php @@ -51,18 +51,18 @@ protected function languageManager() { } /** - * Sets state flags for language_test module. + * Sets key/value pairs for language_test module. * * Ensures to correctly update data both in the child site and the test runner * environment. * * @param array $values - * The key/value pairs to set in state. + * The key/value pairs to set in the key value store. */ - protected function stateSet(array $values) { - // Set the new state values. - $this->container->get('state')->setMultiple($values); - // Refresh in-memory static state/config caches and static variables. + protected function keysValuesSet(array $values): void { + // Set the new key value values. + $this->container->get('keyvalue')->get('language_test')->setMultiple($values); + // Refresh in-memory static key value/config caches and static variables. $this->refreshVariables(); // Refresh/rewrite language negotiation configuration, in order to pick up // the manipulations performed by language_test module's info alter hooks. @@ -73,13 +73,13 @@ protected function stateSet(array $values) { * Tests alterations to language types/negotiation info. */ public function testInfoAlterations(): void { - $this->stateSet([ + $this->keysValuesSet([ // Enable language_test type info. - 'language_test.language_types' => TRUE, + 'language_types' => TRUE, // Enable language_test negotiation info (not altered yet). - 'language_test.language_negotiation_info' => TRUE, + 'language_negotiation_info' => TRUE, // Alter LanguageInterface::TYPE_CONTENT to be configurable. - 'language_test.content_language_type' => TRUE, + 'content_language_type' => TRUE, ]); $this->container->get('module_installer')->install(['language_test']); $this->resetAll(); @@ -109,8 +109,8 @@ public function testInfoAlterations(): void { // Alter language negotiation info to remove interface language negotiation // method. - $this->stateSet([ - 'language_test.language_negotiation_info_alter' => TRUE, + $this->keysValuesSet([ + 'language_negotiation_info_alter' => TRUE, ]); $negotiation = $this->config('language.types')->get('negotiation.' . $type . '.enabled'); -- GitLab