Commit 365358c5 authored by alexpott's avatar alexpott

Issue #2346629 by Sutharsan: Fixed When on report translations page, wrong...

Issue #2346629 by Sutharsan: Fixed When on report translations page, wrong update messages displayed.
parent e114ff92
......@@ -105,7 +105,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
if (!empty($update['not_found'])) {
$languages_not_found[$langcode] = $langcode;
}
elseif (!empty($update['updates'])) {
if (!empty($update['updates'])) {
$languages_update[$langcode] = $langcode;
}
}
......@@ -215,7 +215,7 @@ protected function prepareUpdateData(array $status) {
$remote = isset($project_info->files[LOCALE_TRANSLATION_REMOTE]) ? $project_info->files[LOCALE_TRANSLATION_REMOTE] : NULL;
$recent = _locale_translation_source_compare($local, $remote) == LOCALE_TRANSLATION_SOURCE_COMPARE_LT ? $remote : $local;
$updates[$langcode]['updates'][] = array(
'name' => $project_data[$project_info->name]->info['name'],
'name' => $project_info->name == 'drupal' ? $this->t('Drupal core') : $project_data[$project_info->name]->info['name'],
'version' => $project_info->version,
'timestamp' => $recent->timestamp,
);
......
......@@ -48,9 +48,7 @@ public function testInterface() {
// Add German language.
$this->addLanguage('de');
// Drupal core is probably in 8.x, but tests may also be executed with
// stable releases. As this is an uncontrolled factor in the test, we will
// mark Drupal core as translated and continue with the prepared modules.
// Override Drupal core translation status as 'up-to-date'.
$status = locale_translation_get_status();
$status['drupal']['de']->type = 'current';
\Drupal::state()->set('locale.translation_status', $status);
......@@ -89,6 +87,32 @@ public function testInterface() {
$this->assertText(t('Missing translations for one project'), 'No translations found');
$this->assertText(t('@module (@version).', array('@module' => 'Locale test translate', '@version' => '1.3-dev')), 'Release details');
$this->assertText(t('No translation files are provided for development releases.'), 'Release info');
// Override Drupal core translation status as 'no translations found'.
$status = locale_translation_get_status();
$status['drupal']['de']->type = '';
$status['drupal']['de']->timestamp = 0;
$status['drupal']['de']->version = '8.1.1';
\Drupal::state()->set('locale.translation_status', $status);
// Check if Drupal core is not translated.
$this->drupalGet('admin/reports/translations');
$this->assertText(t('Missing translations for 2 projects'), 'No translations found');
$this->assertText(t('@module (@version).', array('@module' => t('Drupal core'), '@version' => '8.1.1')), 'Release details');
// Override Drupal core translation status as 'translations available'.
$status = locale_translation_get_status();
$status['drupal']['de']->type = 'local';
$status['drupal']['de']->files['local']->timestamp = REQUEST_TIME;
$status['drupal']['de']->files['local']->info['version'] = '8.1.1';
\Drupal::state()->set('locale.translation_status', $status);
// Check if translations are available for Drupal core.
$this->drupalGet('admin/reports/translations');
$this->assertText(t('Updates for: !project', array('!project' => t('Drupal core'))), 'Translations found');
$this->assertText(t('@module (@date)', array('@module' => t('Drupal core'), '@date' => format_date(REQUEST_TIME, 'html_date'))), 'Core translation update');
$update_button = $this->xpath('//input[@type="submit"][@value="' . t('Update translations') . '"]');
$this->assertTrue($update_button, 'Update translations button');
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment