L10nUpdateInterfaceTest.test 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * @file
  4. * Contains L10nUpdateInterfaceTest.
  5. */
  6. /**
  7. * Tests for the l10n_update status user interfaces.
  8. */
  9. class L10nUpdateInterfaceTest extends L10nUpdateTestBase {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Update translations user interface',
  13. 'description' => 'Tests for the user interface of project interface translations.',
  14. 'group' => 'Localization Update',
  15. );
  16. }
  17. function setUp() {
  18. parent::setUp();
  19. $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'translate interface'));
  20. $this->drupalLogin($admin_user);
  21. }
  22. /**
  23. * Tests the user interfaces of the interface translation update system.
  24. *
  25. * Testing the Available updates summary on the side wide status page and the
  26. * Avaiable translation updates page.
  27. */
  28. function testInterface() {
  29. // Enable the module this test uses for its translations.
  30. module_enable(array('l10n_update_test_translate'));
  31. // No language added.
  32. // Check status page and Available translation updates page.
  33. $this->drupalGet('admin/reports/status');
  34. $this->assertNoText(t('Translation update status'), 'No status message');
  35. $this->drupalGet('admin/config/regional/translate/update');
  36. $this->assertRaw(t('No translatable languages available. <a href="@add_language">Add a language</a> first.', array('@add_language' => url('admin/config/regional/language'))), 'Language message');
  37. // Add German language.
  38. $this->addLanguage('de');
  39. // Drupal core is probably in 7.x, but tests may also be executed with
  40. // stable releases. As this is an uncontrolled factor in the test, we will
  41. // mark Drupal core as translated and continue with the prepared modules.
  42. $status = l10n_update_get_status();
  43. $status['drupal']['de']->type = 'current';
  44. variable_set('l10n_update_translation_status', $status);
  45. // One language added, all translations up to date.
  46. $this->drupalGet('admin/reports/status');
  47. $this->assertText(t('Translation update status'), 'Status message');
  48. $this->assertText(t('Up to date'), 'Translations up to date');
  49. $this->drupalGet('admin/config/regional/translate/update');
  50. $this->assertText(t('All translations up to date.'), 'Translations up to date');
  51. // Set l10n_update_test_translate module to have a local translation available.
  52. $status = l10n_update_get_status();
  53. $status['l10n_update_test_translate']['de']->type = 'local';
  54. variable_set('l10n_update_translation_status', $status);
  55. // Check if updates are available for German.
  56. $this->drupalGet('admin/reports/status');
  57. $this->assertText(t('Translation update status'), 'Status message');
  58. $this->assertRaw(t('Updates available for: @languages. See the <a href="@updates">Available translation updates</a> page for more information.', array('@languages' => t('German'), '@updates' => url('admin/config/regional/translate/update'))), 'Updates available message');
  59. $this->drupalGet('admin/config/regional/translate/update');
  60. $this->assertText(t('Updates for: @modules', array('@modules' => 'Localization Update test translate')), 'Translations avaiable');
  61. // Set l10n_update_test_translate module to have a dev release and no
  62. // translation found.
  63. $status = l10n_update_get_status();
  64. $status['l10n_update_test_translate']['de']->version = '1.3-dev';
  65. $status['l10n_update_test_translate']['de']->type = '';
  66. variable_set('l10n_update_translation_status', $status);
  67. // Check if no updates were found.
  68. $this->drupalGet('admin/reports/status');
  69. $this->assertText(t('Translation update status'), 'Status message');
  70. $this->assertRaw(t('Missing translations for: @languages. See the <a href="@updates">Available translation updates</a> page for more information.', array('@languages' => t('German'), '@updates' => url('admin/config/regional/translate/update'))), 'Missing translations message');
  71. $this->drupalGet('admin/config/regional/translate/update');
  72. $this->assertText(t('Missing translations for one project'), 'No translations found');
  73. $this->assertText(t('@module (@version).', array('@module' => 'Localization Update test translate', '@version' => '1.3-dev')), 'Release details');
  74. $this->assertText(t('No translation files are provided for development releases.'), 'Release info');
  75. }
  76. }