You are here

public function TranslationRequestManagerTest::testUpdateExistingTranslationRequest in TMGMT Translator Smartling 8.4

Test update existing request test.

File

tests/src/Kernel/TranslationRequestManagerTest.php, line 308

Class

TranslationRequestManagerTest
Tests TranslationRequestManagerTest class.

Namespace

Drupal\Tests\tmgmt_smartling\Kernel

Code

public function testUpdateExistingTranslationRequest() {
  $translation_request = [
    'translationRequestUid' => 'test_translation_request_uid',
    'translationSubmissions' => [
      [
        'translationSubmissionUid' => 'test_translation_submission_uid',
      ],
    ],
  ];
  $update_submission_params = new UpdateTranslationSubmissionParams();
  $update_submission_params
    ->setSubmitterName('test_submitter')
    ->setCustomTranslationData([
    'batch_uid' => $this->job
      ->getSetting('batch_uid'),
    'batch_execute_on_job' => $this->job
      ->getSetting('batch_execute_on_job'),
  ])
    ->setState(TranslationSubmissionStates::STATE_NEW)
    ->setTranslationSubmissionUid($translation_request['translationSubmissions'][0]['translationSubmissionUid']);
  $update_request_params = new UpdateTranslationRequestParams();
  $update_request_params
    ->setTitle($this->job
    ->label())
    ->addTranslationSubmission($update_submission_params);
  $translation_request_manager_mock = $this
    ->getMockBuilder(TranslationRequestManagerTested::class)
    ->setConstructorArgs([
    $this->apiWrapperMock,
    $this->stateMock,
    $this->loggerMock,
  ])
    ->setMethods([
    'getSubmitterName',
  ])
    ->getMock();
  $translation_request_manager_mock
    ->expects($this
    ->once())
    ->method('getSubmitterName')
    ->with($this->job)
    ->willReturn('test_submitter');
  $this->apiWrapperMock
    ->expects($this
    ->once())
    ->method('updateTranslationRequest')
    ->with('tmgmt_smartling_bucket', 'test_translation_request_uid', $update_request_params);
  $translation_request_manager_mock
    ->updateExistingTranslationRequest($this->job, $translation_request);
}