You are here

protected function LocaleStringTest::createTranslation in Drupal 8

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

Creates single translation for source string.

Parameters

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

string $langcode: The language code.

array $values: The values array.

Return value

\Drupal\locale\StringInterface The translated string object.

2 calls to LocaleStringTest::createTranslation()
LocaleStringTest::createAllTranslations in core/modules/locale/tests/src/Kernel/LocaleStringTest.php
Creates translations for source string and all languages.
LocaleStringTest::testStringCrudApi in core/modules/locale/tests/src/Kernel/LocaleStringTest.php
Test CRUD API.

File

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

Class

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

Namespace

Drupal\Tests\locale\Kernel

Code

protected function createTranslation(StringInterface $source, $langcode, array $values = []) {
  return $this->storage
    ->createTranslation($values + [
    'lid' => $source->lid,
    'language' => $langcode,
    'translation' => $this
      ->randomMachineName(100),
  ])
    ->save();
}