Issue #3496438 by spokje: [random test failure] LanguageNegotiationInfoTest::testInfoAlterations

merge-requests/10614/merge
Lee Rowlands 2025-01-03 13:13:55 +10:00
parent 2d552b3d86
commit 329d60ea30
No known key found for this signature in database
GPG Key ID: 2B829A3DF9204DC4
3 changed files with 16 additions and 16 deletions

View File

@ -73,7 +73,7 @@ class CommentLanguageTest extends BrowserTestBase {
$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

View File

@ -32,7 +32,7 @@ class LanguageTestHooks {
*/
#[Hook('language_types_info')]
public function languageTypesInfo() {
if (\Drupal::state()->get('language_test.language_types')) {
if (\Drupal::keyValue('language_test')->get('language_types')) {
return [
'test_language_type' => [
'name' => t('Test'),
@ -53,7 +53,7 @@ class LanguageTestHooks {
*/
#[Hook('language_types_info_alter')]
public function languageTypesInfoAlter(array &$language_types): void {
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
@ -72,7 +72,7 @@ class LanguageTestHooks {
*/
#[Hook('language_negotiation_info_alter')]
public function languageNegotiationInfoAlter(array &$negotiation_info): void {
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]);
}
}

View File

@ -51,18 +51,18 @@ class LanguageNegotiationInfoTest extends BrowserTestBase {
}
/**
* 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): void {
// 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 @@ class LanguageNegotiationInfoTest extends BrowserTestBase {
* 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 @@ class LanguageNegotiationInfoTest extends BrowserTestBase {
// 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');