You are here

public function UploadFlowTest::testRequestTranslationSuccessFlowDoNotExecute in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.3 tests/src/Kernel/UploadFlowTest.php \Drupal\Tests\tmgmt_smartling\Kernel\UploadFlowTest::testRequestTranslationSuccessFlowDoNotExecute()

Upload success flow without batch execution.

File

tests/src/Kernel/UploadFlowTest.php, line 114

Class

UploadFlowTest
Tests file upload flow.

Namespace

Drupal\Tests\tmgmt_smartling\Kernel

Code

public function testRequestTranslationSuccessFlowDoNotExecute() {
  $translate_job = $this
    ->createJobWithItems([
    'batch_uid' => 'uid',
    'batch_execute_on_job' => 2,
  ]);
  $this->translationRequestManagerMock
    ->expects($this
    ->once())
    ->method('upsertTranslationRequest')
    ->with($translate_job)
    ->willReturn([
    'translationRequestUid' => 'test',
  ]);
  $this->translationRequestManagerMock
    ->expects($this
    ->never())
    ->method('commitError');
  $this->apiWrapperMock
    ->expects($this
    ->once())
    ->method('getApi')
    ->with('batch')
    ->willReturn($this->batchApiMock);
  $this->apiWrapperMock
    ->expects($this
    ->once())
    ->method('createAuditLogRecord')
    ->with($translate_job, NULL, \Drupal::currentUser(), CreateRecordParameters::ACTION_TYPE_UPLOAD);
  $this->batchApiMock
    ->expects($this
    ->once())
    ->method('uploadBatchFile')
    ->with('public://tmgmt_sources/JobID1_en_de.xml', 'JobID1_en_de.xml', 'xml', 'uid', $this
    ->callback([
    $this,
    'assertUploadParameters',
  ]));
  $this->apiWrapperMock
    ->expects($this
    ->never())
    ->method('executeBatch')
    ->with('uid');
  $this->translationRequestManagerMock
    ->expects($this
    ->once())
    ->method('commitSuccessfulUpload')
    ->with($translate_job)
    ->willReturn(TRUE);
  $this->apiWrapperMock
    ->expects($this
    ->once())
    ->method('createFirebaseRecord')
    ->with('tmgmt_smartling', 'notifications', 10, [
    "message" => 'File uploaded. Job id: 1, file name: JobID1_en_de.xml.',
    "type" => "status",
  ]);
  $translate_job
    ->requestTranslation();
}