L10nUpdateInterfaceTest.test 4.6 KB

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