public function LocaleUpdateTest::testEnableUninstallModule in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/locale/src/Tests/LocaleUpdateTest.php \Drupal\locale\Tests\LocaleUpdateTest::testEnableUninstallModule()
Tests automatic translation import when a module is enabled.
File
- core/
modules/ locale/ src/ Tests/ LocaleUpdateTest.php, line 307 - Contains \Drupal\locale\Tests\LocaleUpdateTest.
Class
- LocaleUpdateTest
- Tests for updating the interface translations of projects.
Namespace
Drupal\locale\TestsCode
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 = array(
'modules[Testing][locale_test_translate][enable]' => 'locale_test_translate',
);
$this
->drupalPostForm('admin/modules', $edit, t('Install'));
// Check if translations have been imported.
$this
->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array(
'%number' => 7,
'%update' => 0,
'%delete' => 0,
)), 'One translation file imported.');
$this
->assertTranslation('Tuesday', 'Dienstag', 'de');
$edit = array(
'uninstall[locale_test_translate]' => 1,
);
$this
->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this
->drupalPostForm(NULL, array(), t('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');
}