function InstallerTranslationTest::testInstaller
Same name in other branches
- 9 core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php \Drupal\FunctionalTests\Installer\InstallerTranslationTest::testInstaller()
- 10 core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php \Drupal\FunctionalTests\Installer\InstallerTranslationTest::testInstaller()
- 11.x core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php \Drupal\FunctionalTests\Installer\InstallerTranslationTest::testInstaller()
Verifies the expected behaviors of the installation result.
File
-
core/
tests/ Drupal/ FunctionalTests/ Installer/ InstallerTranslationTest.php, line 71
Class
- InstallerTranslationTest
- Installs Drupal in German and checks resulting site.
Namespace
Drupal\FunctionalTests\InstallerCode
public function testInstaller() {
$this->assertUrl('user/1');
$this->assertSession()
->statusCodeEquals(200);
// Verify German was configured but not English.
$this->drupalGet('admin/config/regional/language');
$this->assertText('German');
$this->assertNoText('English');
// The current container still has the english as current language, rebuild.
$this->rebuildContainer();
/** @var \Drupal\user\Entity\User $account */
$account = User::load(0);
$this->assertEqual($account->language()
->getId(), 'en', 'Anonymous user is English.');
$account = User::load(1);
$this->assertEqual($account->language()
->getId(), 'en', 'Administrator user is English.');
$account = $this->drupalCreateUser();
$this->assertEqual($account->language()
->getId(), 'de', 'New user is German.');
// Ensure that we can enable basic_auth on a non-english site.
$this->drupalPostForm('admin/modules', [
'modules[basic_auth][enable]' => TRUE,
], t('Install'));
$this->assertSession()
->statusCodeEquals(200);
// Assert that the theme CSS was added to the page.
$edit = [
'preprocess_css' => FALSE,
];
$this->drupalPostForm('admin/config/development/performance', $edit, t('Save configuration'));
$this->drupalGet('<front>');
$this->assertRaw('classy/css/components/action-links.css');
// Verify the strings from the translation files were imported.
$test_samples = [
'Save and continue',
'Anonymous',
];
foreach ($test_samples as $sample) {
$edit = [];
$edit['langcode'] = 'de';
$edit['translation'] = 'translated';
$edit['string'] = $sample;
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Filter'));
$this->assertText($sample . ' de');
}
/** @var \Drupal\language\ConfigurableLanguageManager $language_manager */
$language_manager = \Drupal::languageManager();
// Installed in German, configuration should be in German. No German or
// English overrides should be present.
$config = \Drupal::config('user.settings');
$override_de = $language_manager->getLanguageConfigOverride('de', 'user.settings');
$override_en = $language_manager->getLanguageConfigOverride('en', 'user.settings');
$this->assertEqual($config->get('anonymous'), 'Anonymous de');
$this->assertEqual($config->get('langcode'), 'de');
$this->assertTrue($override_de->isNew());
$this->assertTrue($override_en->isNew());
// Assert that adding English makes the English override available.
$edit = [
'predefined_langcode' => 'en',
];
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
$override_en = $language_manager->getLanguageConfigOverride('en', 'user.settings');
$this->assertFalse($override_en->isNew());
$this->assertEqual($override_en->get('anonymous'), 'Anonymous');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.