public function CrudTest::testContinuousTranslators

Test crud operations of jobs.

File

tests/src/Kernel/CrudTest.php, line 614

Class

CrudTest
Basic crud operations for jobs and translators

Namespace

Drupal\Tests\tmgmt\Kernel

Code

public function testContinuousTranslators() {
  $translator = $this
    ->createTranslator();
  $this
    ->assertTrue($translator
    ->getPlugin() instanceof ContinuousTranslatorInterface);
  $job = $this
    ->createJob('en', 'de', 0, [
    'job_type' => Job::TYPE_CONTINUOUS,
  ]);
  $this
    ->assertEquals(Job::TYPE_CONTINUOUS, $job
    ->getJobType());
  $job->translator = $translator
    ->id();
  $job
    ->save();

  // Add a test item.
  $item = $job
    ->addItem('test_source', 'test', 1);

  /** @var ContinuousTranslatorInterface $plugin */
  $plugin = $job
    ->getTranslatorPlugin();
  $plugin
    ->requestJobItemsTranslation([
    $item,
  ]);
  $this
    ->assertEquals('de(de-ch): Text for job item with type test and id 1.', $item
    ->getData()['dummy']['deep_nesting']['#translation']['#text']);
}