function InstallerLanguageTest::testInstallerTranslationFiles

Tests that the installer can find translation files.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Common/InstallerLanguageTest.php, line 33
Definition of Drupal\system\Tests\Common\InstallerLanguageTest.

Class

InstallerLanguageTest
Tests installer language detection.

Namespace

Drupal\system\Tests\Common

Code

function testInstallerTranslationFiles() {
  include_once DRUPAL_ROOT . '/core/includes/install.core.inc';

  // Different translation files would be found depending on which language
  // we are looking for.
  $expected_translation_files = array(
    NULL => array(
      'drupal-8.0.hu.po',
      'drupal-8.0.de.po',
    ),
    'de' => array(
      'drupal-8.0.de.po',
    ),
    'hu' => array(
      'drupal-8.0.hu.po',
    ),
    'it' => array(),
  );
  foreach ($expected_translation_files as $langcode => $files_expected) {
    $files_found = install_find_translation_files($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,
      )));
    }
  }
}