public function L10nUpdateTest::testUpdateCheckStatus in Localization update 7.2
Checks if local or remote translation sources are detected.
The translation status process by default checks the status of the installed projects. For testing purpose a predefined set of modules with fixed file names and release versions is used. This custom project definition is applied using a hook_l10n_update_projects_alter implementation in the l10n_update_test module.
This test generates a set of local and remote translation files in their respective local and remote translation directory. The test checks whether the most recent files are selected in the different check scenarios: check for local files only, check for both local and remote files.
File
- tests/
L10nUpdateTest.test, line 84 - Contains L10nUpdateTest.
Class
- L10nUpdateTest
- Tests for update translations.
Code
public function testUpdateCheckStatus() {
// Set a flag to let the l10n_update_test module replace the project data
// with a set of test projects.
variable_set('l10n_update_test_projects_alter', TRUE);
// Create local and remote translations files.
$this
->setTranslationFiles();
variable_set('l10n_update_default_filename', '%project-%release.%language._po');
// Set the test conditions.
$edit = array(
'l10n_update_check_mode' => L10N_UPDATE_USE_SOURCE_LOCAL,
);
$this
->drupalPost('admin/config/regional/language/update', $edit, t('Save configuration'));
// Get status of translation sources at local file system.
$this
->drupalGet('admin/config/regional/translate/check');
$result = l10n_update_get_status();
$this
->assertEqual($result['contrib_module_one']['de']->type, L10N_UPDATE_LOCAL, 'Translation of contrib_module_one found');
$this
->assertEqual($result['contrib_module_one']['de']->timestamp, $this->timestamp_old, 'Translation timestamp found');
$this
->assertEqual($result['contrib_module_two']['de']->type, L10N_UPDATE_LOCAL, 'Translation of contrib_module_two found');
$this
->assertEqual($result['contrib_module_two']['de']->timestamp, $this->timestamp_new, 'Translation timestamp found');
$this
->assertEqual($result['l10n_update_test']['de']->type, L10N_UPDATE_LOCAL, 'Translation of l10n_update_test found');
$this
->assertEqual($result['custom_module_one']['de']->type, L10N_UPDATE_LOCAL, 'Translation of custom_module_one found');
// Set the test conditions.
$edit = array(
'l10n_update_check_mode' => L10N_UPDATE_USE_SOURCE_REMOTE_AND_LOCAL,
);
$this
->drupalPost('admin/config/regional/language/update', $edit, t('Save configuration'));
// Get status of translation sources at both local and remote locations.
$this
->drupalGet('admin/config/regional/translate/check');
$result = l10n_update_get_status();
$this
->assertEqual($result['contrib_module_one']['de']->type, L10N_UPDATE_REMOTE, 'Translation of contrib_module_one found');
$this
->assertEqual($result['contrib_module_one']['de']->timestamp, $this->timestamp_new, 'Translation timestamp found');
$this
->assertEqual($result['contrib_module_two']['de']->type, L10N_UPDATE_LOCAL, 'Translation of contrib_module_two found');
$this
->assertEqual($result['contrib_module_two']['de']->timestamp, $this->timestamp_new, 'Translation timestamp found');
$this
->assertEqual($result['contrib_module_three']['de']->type, L10N_UPDATE_LOCAL, 'Translation of contrib_module_three found');
$this
->assertEqual($result['contrib_module_three']['de']->timestamp, $this->timestamp_old, 'Translation timestamp found');
$this
->assertEqual($result['l10n_update_test']['de']->type, L10N_UPDATE_LOCAL, 'Translation of l10n_update_test found');
$this
->assertEqual($result['custom_module_one']['de']->type, L10N_UPDATE_LOCAL, 'Translation of custom_module_one found');
}