'Update translations user interface',
'description' => 'Tests for the user interface of project interface translations.',
'group' => 'Localization Update',
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'translate interface'));
$this->drupalLogin($admin_user);
}
/**
* Tests the user interfaces of the interface translation update system.
*
* Testing the Available updates summary on the side wide status page and the
* Avaiable translation updates page.
*/
public function testInterface() {
// Enable the module this test uses for its translations.
module_enable(array('l10n_update_test_translate'));
// Exclude l10n_update so no remote translations are fetched.
$edit = array(
'disabled_projects' => "l10n_update",
);
$this->drupalPost('admin/config/regional/language/update', $edit, t('Save configuration'));
// No language added.
// Check status page and Translate interface update page.
$this->drupalGet('admin/reports/status');
$this->assertNoText(t('Translation update status'), 'No status message');
$this->drupalGet('admin/config/regional/translate/update');
$this->assertRaw(t('No translatable languages available. Add a language first.', array('@add_language' => url('admin/config/regional/language'))), 'Language message');
// Add German language.
$this->addLanguage('de');
// Drupal core is probably in 7.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.
$status = l10n_update_get_status();
$status['drupal']['de']->type = 'current';
cache_set('l10n_update_status', $status);
// One language added, all translations up to date.
$this->drupalGet('admin/reports/status');
$this->assertText(t('Translation update status'), 'Status message');
$this->assertText(t('Up to date'), 'Translations up to date');
$this->drupalGet('admin/config/regional/translate/update');
$this->assertText(t('All translations up to date.'), 'Translations up to date');
// Set l10n_update_test_translate module to have a local translation
// available.
$status = l10n_update_get_status();
$status['l10n_update_test_translate']['de']->type = 'local';
cache_set('l10n_update_status', $status);
// Check if updates are available for German.
$this->drupalGet('admin/reports/status');
$this->assertText(t('Translation update status'), 'Status message');
$this->assertRaw(t('Updates available for: @languages. See the Translate interface update page for more information.', array('@languages' => t('German'), '@updates' => url('admin/config/regional/translate/update'))), 'Updates available message');
$this->drupalGet('admin/config/regional/translate/update');
$this->assertText(t('Updates for: @modules', array('@modules' => 'Localization Update test translate')), 'Translations avaiable');
// Set l10n_update_test_translate module to have a dev release and no
// translation found.
$status = l10n_update_get_status();
$status['l10n_update_test_translate']['de']->version = '1.3-dev';
$status['l10n_update_test_translate']['de']->type = '';
cache_set('l10n_update_status', $status);
// Check if no updates were found.
$this->drupalGet('admin/reports/status');
$this->assertText(t('Translation update status'), 'Status message');
$this->assertRaw(t('Missing translations for: @languages. See the Translate interface update page for more information.', array('@languages' => t('German'), '@updates' => url('admin/config/regional/translate/update'))), 'Missing translations message');
$this->drupalGet('admin/config/regional/translate/update');
$this->assertText(t('Missing translations for one project'), 'No translations found');
$this->assertText(t('@module (@version).', array('@module' => 'Localization Update test translate', '@version' => '1.3-dev')), 'Release details');
$this->assertText(t('No translation files are provided for development releases.'), 'Release info');
}
}