Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Installer / InstallerLanguageTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Installer;
4
5 use Drupal\Core\StringTranslation\Translator\FileTranslation;
6 use Drupal\KernelTests\KernelTestBase;
7
8 /**
9  * Tests for installer language support.
10  *
11  * @group Installer
12  */
13 class InstallerLanguageTest extends KernelTestBase {
14
15   /**
16    * Tests that the installer can find translation files.
17    */
18   public function testInstallerTranslationFiles() {
19     // Different translation files would be found depending on which language
20     // we are looking for.
21     $expected_translation_files = [
22       NULL => ['drupal-8.0.0-beta2.hu.po', 'drupal-8.0.0.de.po'],
23       'de' => ['drupal-8.0.0.de.po'],
24       'hu' => ['drupal-8.0.0-beta2.hu.po'],
25       'it' => [],
26     ];
27
28     // Hardcode the simpletest module location as we don't yet know where it is.
29     // @todo Remove as part of https://www.drupal.org/node/2186491
30     $file_translation = new FileTranslation('core/modules/simpletest/files/translations');
31     foreach ($expected_translation_files as $langcode => $files_expected) {
32       $files_found = $file_translation->findTranslationFiles($langcode);
33       $this->assertTrue(count($files_found) == count($files_expected), format_string('@count installer languages found.', ['@count' => count($files_expected)]));
34       foreach ($files_found as $file) {
35         $this->assertTrue(in_array($file->filename, $files_expected), format_string('@file found.', ['@file' => $file->filename]));
36       }
37     }
38   }
39
40   /**
41    * Tests profile info caching in non-English languages.
42    */
43   public function testInstallerTranslationCache() {
44     require_once 'core/includes/install.inc';
45
46     // Prime the drupal_get_filename() static cache with the location of the
47     // testing profile as it is not the currently active profile and we don't
48     // yet have any cached way to retrieve its location.
49     // @todo Remove as part of https://www.drupal.org/node/2186491
50     drupal_get_filename('profile', 'testing', 'core/profiles/testing/testing.info.yml');
51
52     $info_en = install_profile_info('testing', 'en');
53     $info_nl = install_profile_info('testing', 'nl');
54
55     $this->assertNotContains('locale', $info_en['install'], 'Locale is not set when installing in English.');
56     $this->assertContains('locale', $info_nl['install'], 'Locale is set when installing in Dutch.');
57   }
58
59 }