Tests automatic translation import when a module is enabled.
function testEnableDisableModule() {
// 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
->drupalPost('admin/modules', $edit, t('Save configuration'));
// 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');
// Disable and uninstall a module.
$edit = array(
'modules[Testing][locale_test_translate][enable]' => FALSE,
);
$this
->drupalPost('admin/modules', $edit, t('Save configuration'));
$edit = array(
'uninstall[locale_test_translate]' => 1,
);
$this
->drupalPost('admin/modules/uninstall', $edit, t('Uninstall'));
$this
->drupalPost(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');
}