public function DownloadFlowTest::testDownloadSuccessFullFlow in TMGMT Translator Smartling 8.3
Same name and namespace in other branches
- 8.4 tests/src/Kernel/DownloadFlowTest.php \Drupal\Tests\tmgmt_smartling\Kernel\DownloadFlowTest::testDownloadSuccessFullFlow()
Download success full flow.
File
- tests/
src/ Kernel/ DownloadFlowTest.php, line 17
Class
- DownloadFlowTest
- Tests file download flow.
Namespace
Drupal\Tests\tmgmt_smartling\KernelCode
public function testDownloadSuccessFullFlow() {
$translate_job = $this
->createJobWithItems([
'batch_uid' => 'uid',
'batch_execute_on_job' => 1,
]);
$this->apiWrapperMock
->expects($this
->once())
->method('getApi')
->with('file')
->willReturn($this->fileApiMock);
$this->apiWrapperMock
->expects($this
->once())
->method('createAuditLogRecord')
->with($translate_job, NULL, \Drupal::currentUser(), CreateRecordParameters::ACTION_TYPE_DOWNLOAD);
$this->fileApiMock
->expects($this
->once())
->method('downloadFile')
->with('JobID1_en_de.xml', 'de', $this
->callback(function ($subject) {
$params = $subject
->exportToArray();
return $params['retrievalType'] == 'published';
}))
->willReturn('xml');
$this->pluginMock
->expects($this
->once())
->method('validateImport')
->with('public://tmgmt_smartling_translations/JobID1_en_de.xml', $translate_job)
->willReturn(TRUE);
$this->pluginMock
->expects($this
->once())
->method('import')
->with('public://tmgmt_smartling_translations/JobID1_en_de.xml', $translate_job)
->willReturn([]);
$this->apiWrapperMock
->expects($this
->at(2))
->method('createFirebaseRecord')
->with('tmgmt_smartling', 'notifications', 10, [
"message" => 'Translation for "public://tmgmt_smartling_translations/JobID1_en_de.xml" (job id = 1) was successfully downloaded and imported.',
"type" => "status",
]);
tmgmt_smartling_download_file($translate_job);
}