Chris@0: drupalCreateUser(['administer site configuration', 'administer languages']); Chris@0: $this->drupalLogin($adminUser); Chris@0: Chris@0: // Add a custom language. Chris@0: $langcode = 'xx'; Chris@0: $name = $this->randomMachineName(16); Chris@0: $edit = [ Chris@0: 'predefined_langcode' => 'custom', Chris@0: 'langcode' => $langcode, Chris@0: 'label' => $name, Chris@0: 'direction' => LanguageInterface::DIRECTION_LTR, Chris@0: ]; Chris@0: $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); Chris@0: \Drupal::languageManager() Chris@0: ->getLanguageConfigOverride($langcode, 'system.site') Chris@0: ->set('name', 'XX site name') Chris@0: ->save(); Chris@0: Chris@0: // Place branding block with site name into header region. Chris@0: $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']); Chris@0: Chris@0: $this->drupalLogout(); Chris@0: Chris@0: // The home page in English should not have the override. Chris@0: $this->drupalGet(''); Chris@0: $this->assertNoText('XX site name'); Chris@0: Chris@0: // During path resolution the system.site configuration object is used to Chris@0: // determine the front page. This occurs before language negotiation causing Chris@0: // the configuration factory to cache an object without the correct Chris@0: // overrides. We are testing that the configuration factory is Chris@0: // re-initialised after language negotiation. Ensure that it applies when Chris@0: // we access the XX front page. Chris@0: // @see \Drupal\Core\PathProcessor::processInbound() Chris@0: $this->drupalGet('xx'); Chris@0: $this->assertText('XX site name'); Chris@0: Chris@0: // Set the xx language to be the default language and delete the English Chris@0: // language so the site is no longer multilingual and confirm configuration Chris@0: // overrides still work. Chris@0: $language_manager = \Drupal::languageManager()->reset(); Chris@0: $this->assertTrue($language_manager->isMultilingual(), 'The test site is multilingual.'); Chris@0: $this->config('system.site')->set('default_langcode', 'xx')->save(); Chris@0: Chris@0: ConfigurableLanguage::load('en')->delete(); Chris@0: $this->assertFalse($language_manager->isMultilingual(), 'The test site is monolingual.'); Chris@0: Chris@0: $this->drupalGet('xx'); Chris@0: $this->assertText('XX site name'); Chris@0: Chris@0: } Chris@0: Chris@0: }