comparison core/modules/locale/tests/src/Functional/LocaleUpdateTest.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
25 // not be chosen randomly. 25 // not be chosen randomly.
26 $this->addLanguage('de'); 26 $this->addLanguage('de');
27 } 27 }
28 28
29 /** 29 /**
30 * Checks if a list of translatable projects gets build.
31 */
32 public function testUpdateProjects() {
33 module_load_include('compare.inc', 'locale');
34
35 // Make the test modules look like a normal custom module. i.e. make the
36 // modules not hidden. locale_test_system_info_alter() modifies the project
37 // info of the locale_test and locale_test_translate modules.
38 \Drupal::state()->set('locale.test_system_info_alter', TRUE);
39 $this->resetAll();
40
41 // Check if interface translation data is collected from hook_info.
42 $projects = locale_translation_project_list();
43 $this->assertFalse(isset($projects['locale_test_translate']), 'Hidden module not found');
44 $this->assertEqual($projects['locale_test']['info']['interface translation server pattern'], 'core/modules/locale/test/test.%language.po', 'Interface translation parameter found in project info.');
45 $this->assertEqual($projects['locale_test']['name'], 'locale_test', format_string('%key found in project info.', ['%key' => 'interface translation project']));
46 }
47
48 /**
49 * Checks if local or remote translation sources are detected. 30 * Checks if local or remote translation sources are detected.
50 * 31 *
51 * The translation status process by default checks the status of the 32 * The translation status process by default checks the status of the
52 * installed projects. For testing purpose a predefined set of modules with 33 * installed projects. For testing purpose a predefined set of modules with
53 * fixed file names and release versions is used. This custom project 34 * fixed file names and release versions is used. This custom project
134 $this->drupalGet('admin/reports/translations/check'); 115 $this->drupalGet('admin/reports/translations/check');
135 116
136 // Check the status on the Available translation status page. 117 // Check the status on the Available translation status page.
137 $this->assertRaw('<label for="edit-langcodes-de" class="visually-hidden">Update German</label>', 'German language found'); 118 $this->assertRaw('<label for="edit-langcodes-de" class="visually-hidden">Update German</label>', 'German language found');
138 $this->assertText('Updates for: Contributed module one, Contributed module two, Custom module one, Locale test', 'Updates found'); 119 $this->assertText('Updates for: Contributed module one, Contributed module two, Custom module one, Locale test', 'Updates found');
139 $this->assertText('Contributed module one (' . format_date($this->timestampNew, 'html_date') . ')', 'Updates for Contrib module one'); 120 /** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */
140 $this->assertText('Contributed module two (' . format_date($this->timestampNew, 'html_date') . ')', 'Updates for Contrib module two'); 121 $date_formatter = $this->container->get('date.formatter');
122 $this->assertText('Contributed module one (' . $date_formatter->format($this->timestampNew, 'html_date') . ')', 'Updates for Contrib module one');
123 $this->assertText('Contributed module two (' . $date_formatter->format($this->timestampNew, 'html_date') . ')', 'Updates for Contrib module two');
141 124
142 // Execute the translation update. 125 // Execute the translation update.
143 $this->drupalPostForm('admin/reports/translations', [], t('Update translations')); 126 $this->drupalPostForm('admin/reports/translations', [], t('Update translations'));
144 127
145 // Check if the translation has been updated, using the status cache. 128 // Check if the translation has been updated, using the status cache.