function LocaleUpdateTest::testEnableUninstallModule
Same name in other branches
- 8.9.x core/modules/locale/tests/src/Functional/LocaleUpdateTest.php \Drupal\Tests\locale\Functional\LocaleUpdateTest::testEnableUninstallModule()
- 10 core/modules/locale/tests/src/Functional/LocaleUpdateTest.php \Drupal\Tests\locale\Functional\LocaleUpdateTest::testEnableUninstallModule()
- 11.x core/modules/locale/tests/src/Functional/LocaleUpdateTest.php \Drupal\Tests\locale\Functional\LocaleUpdateTest::testEnableUninstallModule()
Tests automatic translation import when a module is enabled.
File
-
core/
modules/ locale/ tests/ src/ Functional/ LocaleUpdateTest.php, line 321
Class
- LocaleUpdateTest
- Tests for updating the interface translations of projects.
Namespace
Drupal\Tests\locale\FunctionalCode
public function testEnableUninstallModule() {
// Make the hidden test modules look like a normal custom module.
\Drupal::state()->set('locale.test_system_info_alter', TRUE);
// Check if there is no translation yet.
$this->assertTranslation('Tuesday', '', 'de');
// Enable a module.
$edit = [
'modules[locale_test_translate][enable]' => 'locale_test_translate',
];
$this->drupalGet('admin/modules');
$this->submitForm($edit, 'Install');
// Check if translations have been imported.
$this->assertSession()
->pageTextContains("One translation file imported. 7 translations were added, 0 translations were updated and 0 translations were removed.");
// cSpell:disable-next-line
$this->assertTranslation('Tuesday', 'Dienstag', 'de');
$edit = [
'uninstall[locale_test_translate]' => 1,
];
$this->drupalGet('admin/modules/uninstall');
$this->submitForm($edit, 'Uninstall');
$this->submitForm([], 'Uninstall');
// Check if the file data is removed from the database.
$history = locale_translation_get_file_history();
$this->assertFalse(isset($history['locale_test_translate']), 'Project removed from the file history');
$projects = locale_translation_get_projects();
$this->assertFalse(isset($projects['locale_test_translate']), 'Project removed from the project list');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.