function LocaleThemeInstallTest::testThemeInstallRewritesConfigLangcode

Same name and namespace in other branches
  1. main core/modules/locale/tests/src/Functional/LocaleThemeInstallTest.php \Drupal\Tests\locale\Functional\LocaleThemeInstallTest::testThemeInstallRewritesConfigLangcode()

Tests that installing a theme via the UI updates config language.

The olivero theme ships core.date_format.olivero_medium with langcode 'en'. With locale enabled and a non-English site default, that langcode should be rewritten to the site default after the install batch runs.

File

core/modules/locale/tests/src/Functional/LocaleThemeInstallTest.php, line 70

Class

LocaleThemeInstallTest
Tests that locale rewrites config langcodes after theme install.

Namespace

Drupal\Tests\locale\Functional

Code

public function testThemeInstallRewritesConfigLangcode() : void {
  // Install olivero via the Appearance UI.
  $this->drupalGet('admin/appearance');
  $this->cssSelect('a[title="Install Olivero theme"]')[0]
    ->click();
  // The ThemeController redirects to the batch page; follow its meta-refresh
  // chain to process all batch operations before asserting config state.
  $this->checkForMetaRefresh();
  $this->rebuildContainer();
  // core.date_format.olivero_medium ships with langcode 'en'. Locale's
  // updateDefaultConfigLangcodes() should have rewritten it to 'de'.
  $langcode = $this->config('core.date_format.olivero_medium')
    ->get('langcode');
  $this->assertSame('de', $langcode);
  // Ensure that the theme is installed.
  $this->assertSession()
    ->addressEquals('admin/appearance');
  $this->assertSession()
    ->pageTextContains('The Olivero theme has been installed.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.