View source
<?php
namespace Drupal\KernelTests\Core\Installer;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Extension\ProfileExtensionList;
use Drupal\Core\StringTranslation\Translator\FileTranslation;
use Drupal\KernelTests\KernelTestBase;
class InstallerLanguageTest extends KernelTestBase {
public function testInstallerTranslationFiles() {
$expected_translation_files = [
NULL => [
'drupal-8.0.0-beta2.hu.po',
'drupal-8.0.0.de.po',
'drupal-8.0.x.fr-CA.po',
],
'de' => [
'drupal-8.0.0.de.po',
],
'fr-CA' => [
'drupal-8.0.x.fr-CA.po',
],
'hu' => [
'drupal-8.0.0-beta2.hu.po',
],
'it' => [],
];
$file_translation = new FileTranslation('core/tests/fixtures/files/translations', $this->container
->get('file_system'));
foreach ($expected_translation_files as $langcode => $files_expected) {
$files_found = $file_translation
->findTranslationFiles($langcode);
$this
->assertSameSize($files_expected, $files_found, new FormattableMarkup('@count installer languages found.', [
'@count' => count($files_expected),
]));
foreach ($files_found as $file) {
$this
->assertContains($file->filename, $files_expected, new FormattableMarkup('@file found.', [
'@file' => $file->filename,
]));
}
}
}
public function testInstallerTranslationCache() {
require_once 'core/includes/install.inc';
$profile_list = \Drupal::service('extension.list.profile');
assert($profile_list instanceof ProfileExtensionList);
$profile_list
->setPathname('testing', 'core/profiles/testing/testing.info.yml');
$info_en = install_profile_info('testing', 'en');
$info_nl = install_profile_info('testing', 'nl');
$this
->assertNotContains('locale', $info_en['install'], 'Locale is not set when installing in English.');
$this
->assertContains('locale', $info_nl['install'], 'Locale is set when installing in Dutch.');
}
}