You are here

protected function LocaleStringTest::createAllTranslations in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/locale/tests/src/Kernel/LocaleStringTest.php \Drupal\Tests\locale\Kernel\LocaleStringTest::createAllTranslations()

Creates translations for source string and all languages.

Parameters

\Drupal\locale\StringInterface $source: The source string.

array $values: The values array.

Return value

array Translation list.

2 calls to LocaleStringTest::createAllTranslations()
LocaleStringTest::testStringCrudApi in core/modules/locale/tests/src/Kernel/LocaleStringTest.php
Tests CRUD API.
LocaleStringTest::testStringSearchApi in core/modules/locale/tests/src/Kernel/LocaleStringTest.php
Tests Search API loading multiple objects.

File

core/modules/locale/tests/src/Kernel/LocaleStringTest.php, line 212

Class

LocaleStringTest
Tests the locale string storage, string objects and data API.

Namespace

Drupal\Tests\locale\Kernel

Code

protected function createAllTranslations(StringInterface $source, array $values = []) {
  $list = [];

  /** @var \Drupal\Core\Language\LanguageManagerInterface $language_manager */
  $language_manager = $this->container
    ->get('language_manager');
  foreach ($language_manager
    ->getLanguages() as $language) {
    $list[$language
      ->getId()] = $this
      ->createTranslation($source, $language
      ->getId(), $values);
  }
  return $list;
}