ConfigLanguageOverrideWebTest.php in Zircon Profile 8.0
File
core/modules/config/src/Tests/ConfigLanguageOverrideWebTest.php
View source
<?php
namespace Drupal\config\Tests;
use Drupal\Core\Language\LanguageInterface;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase;
class ConfigLanguageOverrideWebTest extends WebTestBase {
public static $modules = [
'block',
'language',
'system',
];
protected function setUp() {
parent::setUp();
}
function testSiteNameTranslation() {
$adminUser = $this
->drupalCreateUser(array(
'administer site configuration',
'administer languages',
));
$this
->drupalLogin($adminUser);
$langcode = 'xx';
$name = $this
->randomMachineName(16);
$edit = array(
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
);
$this
->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
\Drupal::languageManager()
->getLanguageConfigOverride($langcode, 'system.site')
->set('name', 'XX site name')
->save();
$this
->drupalPlaceBlock('system_branding_block', [
'region' => 'header',
]);
$this
->drupalLogout();
$this
->drupalGet('');
$this
->assertNoText('XX site name');
$this
->drupalGet('xx');
$this
->assertText('XX site name');
$language_manager = \Drupal::languageManager()
->reset();
$this
->assertTrue($language_manager
->isMultilingual(), 'The test site is multilingual.');
$this
->config('system.site')
->set('default_langcode', 'xx')
->save();
ConfigurableLanguage::load('en')
->delete();
$this
->assertFalse($language_manager
->isMultilingual(), 'The test site is monolingual.');
$this
->drupalGet('xx');
$this
->assertText('XX site name');
}
}