InstallerLanguageTest.php in Zircon Profile 8
File
core/modules/system/src/Tests/Installer/InstallerLanguageTest.php
View source
<?php
namespace Drupal\system\Tests\Installer;
use Drupal\simpletest\KernelTestBase;
use Drupal\Core\StringTranslation\Translator\FileTranslation;
class InstallerLanguageTest extends KernelTestBase {
function testInstallerTranslationFiles() {
$expected_translation_files = array(
NULL => array(
'drupal-8.0.0-beta2.hu.po',
'drupal-8.0.0.de.po',
),
'de' => array(
'drupal-8.0.0.de.po',
),
'hu' => array(
'drupal-8.0.0-beta2.hu.po',
),
'it' => array(),
);
$file_translation = new FileTranslation('core/modules/simpletest/files/translations');
foreach ($expected_translation_files as $langcode => $files_expected) {
$files_found = $file_translation
->findTranslationFiles($langcode);
$this
->assertTrue(count($files_found) == count($files_expected), format_string('@count installer languages found.', array(
'@count' => count($files_expected),
)));
foreach ($files_found as $file) {
$this
->assertTrue(in_array($file->filename, $files_expected), format_string('@file found.', array(
'@file' => $file->filename,
)));
}
}
}
function testInstallerTranslationCache() {
require_once 'core/includes/install.inc';
drupal_get_filename('profile', 'testing', 'core/profiles/testing/testing.info.yml');
$info_en = install_profile_info('testing', 'en');
$info_nl = install_profile_info('testing', 'nl');
$this
->assertFalse(in_array('locale', $info_en['dependencies']), 'Locale is not set when installing in English.');
$this
->assertTrue(in_array('locale', $info_nl['dependencies']), 'Locale is set when installing in Dutch.');
}
}