You are here

function PluginsTest::createJobWithItems in Translation Management Tool 8

1 call to PluginsTest::createJobWithItems()
PluginsTest::testBasicWorkflow in tests/src/Kernel/PluginsTest.php

File

tests/src/Kernel/PluginsTest.php, line 23

Class

PluginsTest
Tests interaction between core and the plugins.

Namespace

Drupal\Tests\tmgmt\Kernel

Code

function createJobWithItems($action = 'translate') {
  $job = parent::createJob();
  for ($i = 1; $i < 3; $i++) {
    if ($i == 3) {

      // Explicitly define the data for the third item.
      $data['data'] = array(
        'dummy' => array(
          'deep_nesting' => array(
            '#text' => 'Stored data',
          ),
        ),
      );
      $job
        ->addItem('test_source', 'test', $i, array(
        $data,
      ));
    }
    $job
      ->addItem('test_source', 'test', $i);
  }

  // Manually specify the translator for now.
  $job->translator = $this->default_translator
    ->id();
  $job->settings = array(
    'action' => $action,
  );
  return $job;
}