function TmgmtTestTrait::createTranslator

Creates, saves and returns a translator.

Return value

\Drupal\tmgmt\TranslatorInterface

11 calls to TmgmtTestTrait::createTranslator()
FileTranslatorTest::testPrivate in translators/tmgmt_file/tests/src/Functional/FileTranslatorTest.php
Tests storing files in the private file system.
FileTranslatorTest::testXLIFFCDATA in translators/tmgmt_file/tests/src/Functional/FileTranslatorTest.php
Test the CDATA option for XLIFF export and import.
FileTranslatorTest::testXLIFFTextProcessing in translators/tmgmt_file/tests/src/Functional/FileTranslatorTest.php
Test the content processing for XLIFF export and import.
LocalTranslatorContinuousTest::testContinuousJobs in translators/tmgmt_local/tests/src/Functional/LocalTranslatorContinuousTest.php
Test continuous Jobs in TMGMT local.
TMGMTUiJavascriptTest::testItemRevision in tests/src/FunctionalJavascript/TMGMTUiJavascriptTest.php
Test the Revisions of a job item.

... See full list

File

tests/src/Functional/TmgmtTestTrait.php, line 117

Class

TmgmtTestTrait
Base class for tests.

Namespace

Drupal\Tests\tmgmt\Functional

Code

function createTranslator(array $values = []) {
  $translator = Translator::create($values + [
    'name' => strtolower($this
      ->randomMachineName()),
    'label' => $this
      ->randomMachineName(),
    'plugin' => 'test_translator',
    'remote_languages_mappings' => [],
    'settings' => empty($values['plugin']) ? [
      'key' => $this
        ->randomMachineName(),
      'another_key' => $this
        ->randomMachineName(),
    ] : [],
  ]);
  $this
    ->assertEquals(SAVED_NEW, $translator
    ->save());
  return $translator;
}