You are here

public function DownloadFlowTest::testDownloadFailFlowGetTranslationRequestFailed in TMGMT Translator Smartling 8.4

Download fail flow: get translation request failed.

File

tests/src/Kernel/DownloadFlowTest.php, line 103

Class

DownloadFlowTest
Tests file download flow.

Namespace

Drupal\Tests\tmgmt_smartling\Kernel

Code

public function testDownloadFailFlowGetTranslationRequestFailed() {
  $translate_job = $this
    ->createJobWithItems([
    'batch_uid' => 'uid',
    'batch_execute_on_job' => 1,
  ]);
  $this->translationRequestManagerMock
    ->expects($this
    ->never())
    ->method('commitError');
  $this->translationRequestManagerMock
    ->expects($this
    ->once())
    ->method('getTranslationRequest')
    ->with($translate_job)
    ->willReturn(FALSE);
  $this->apiWrapperMock
    ->expects($this
    ->never())
    ->method('getApi');
  $this->fileApiMock
    ->expects($this
    ->never())
    ->method('downloadFile');
  $this->translationRequestManagerMock
    ->expects($this
    ->never())
    ->method('commitSuccessfulDownload');
  $this->pluginMock
    ->expects($this
    ->never())
    ->method('validateImport');
  $this->pluginMock
    ->expects($this
    ->never())
    ->method('import');
  $this->apiWrapperMock
    ->expects($this
    ->once())
    ->method('createFirebaseRecord')
    ->with('tmgmt_smartling', 'notifications', 10, [
    "message" => 'File JobID1_en_de.xml (job id = 1) wasn\'t downloaded: can\'t find related translation request. See logs for more info.',
    "type" => "error",
  ]);
  tmgmt_smartling_download_file($translate_job);
}