You are here

public function TranslationRequestManagerTest::testCommitSuccessfulDownloadDoNotChangeState in TMGMT Translator Smartling 8.4

Test download success flow: do not change state.

File

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

Class

TranslationRequestManagerTest
Tests TranslationRequestManagerTest class.

Namespace

Drupal\Tests\tmgmt_smartling\Kernel

Code

public function testCommitSuccessfulDownloadDoNotChangeState() {
  $translation_request = [
    'translationRequestUid' => 'test_translation_request_uid',
    'translationSubmissions' => [
      [
        'translationSubmissionUid' => 'test_translation_submission_uid',
        'state' => TranslationSubmissionStates::STATE_IN_PROGRESS,
      ],
    ],
  ];
  $translation_request_manager_mock = $this
    ->getMockBuilder(TranslationRequestManager::class)
    ->setConstructorArgs([
    $this->apiWrapperMock,
    $this->stateMock,
    $this->loggerMock,
  ])
    ->setMethods([
    'initApiWrapper',
  ])
    ->getMock();
  $translation_request_manager_mock
    ->expects($this
    ->once())
    ->method('initApiWrapper')
    ->with($this->job);
  $update_submission_params = new UpdateTranslationSubmissionParams();
  $update_submission_params
    ->setLastExportedDate(new \DateTime('now', new \DateTimeZone('UTC')))
    ->setTranslationSubmissionUid($translation_request['translationSubmissions'][0]['translationSubmissionUid']);
  $update_request_params = new UpdateTranslationRequestParams();
  $update_request_params
    ->addTranslationSubmission($update_submission_params);
  $this->apiWrapperMock
    ->expects($this
    ->once())
    ->method('updateTranslationRequest')
    ->with('tmgmt_smartling_bucket', 'test_translation_request_uid', $update_request_params);
  $translation_request_manager_mock
    ->commitSuccessfulDownload($this->job, $translation_request);
}