summaryrefslogtreecommitdiff
path: root/sites/all/modules/l10n_update/tests/L10nUpdateInterfaceTest.test
blob: 4ce23ab57881c64babfa499b9cd529164a1c3e0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php

/**
 * @file
 * Contains L10nUpdateInterfaceTest.
 */

/**
 * Tests for the l10n_update status user interfaces.
 */
class L10nUpdateInterfaceTest extends L10nUpdateTestBase {

  public static function getInfo() {
    return array(
      'name' => 'Update translations user interface',
      'description' => 'Tests for the user interface of project interface translations.',
      'group' => 'Localization Update',
    );
  }

  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.
   */
  function testInterface() {
    // Enable the module this test uses for its translations.
    module_enable(array('l10n_update_test_translate'));

    // No language added.
    // Check status page and Available translation updates 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. <a href="@add_language">Add a language</a> 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';
    variable_set('l10n_update_translation_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';
    variable_set('l10n_update_translation_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 <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');
    $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 = '';
    variable_set('l10n_update_translation_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 <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');
    $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');
  }

}