You are here

public function UploadFlowTest::testRequestTranslationFailFlowTranslationRequestUpsertFailed in TMGMT Translator Smartling 8.4

Upload fail flow: translation request upsert failed.

File

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

Class

UploadFlowTest
Tests file upload flow.

Namespace

Drupal\Tests\tmgmt_smartling\Kernel

Code

public function testRequestTranslationFailFlowTranslationRequestUpsertFailed() {
  $translate_job = $this
    ->createJobWithItems([
    'batch_uid' => 'uid',
    'batch_execute_on_job' => 1,
  ]);
  $this->translationRequestManagerMock
    ->expects($this
    ->once())
    ->method('upsertTranslationRequest')
    ->with($translate_job)
    ->willReturn(FALSE);
  $this->translationRequestManagerMock
    ->expects($this
    ->never())
    ->method('commitError');
  $this->apiWrapperMock
    ->expects($this
    ->never())
    ->method('getApi');
  $this->batchApiMock
    ->expects($this
    ->never())
    ->method('uploadBatchFile');
  $this->apiWrapperMock
    ->expects($this
    ->never())
    ->method('executeBatch');
  $this->translationRequestManagerMock
    ->expects($this
    ->never())
    ->method('commitSuccessfulUpload');
  $this->apiWrapperMock
    ->expects($this
    ->once())
    ->method('createFirebaseRecord')
    ->with('tmgmt_smartling', 'notifications', 10, [
    "message" => "Can't upsert translation request. File JobID1_en_de.xml (job id = 1) wasn't uploaded. Please see logs for more info.",
    "type" => "error",
  ]);
  $translate_job
    ->requestTranslation();
}