protected function SmartlingTestBase::requestTranslationForNode in TMGMT Translator Smartling 8.4
Same name and namespace in other branches
- 8.3 tests/src/Functional/SmartlingTestBase.php \Drupal\Tests\tmgmt_smartling\Functional\SmartlingTestBase::requestTranslationForNode()
Requests translation for a given node.
Parameters
$nid:
$language:
$translator:
Return value
20 calls to SmartlingTestBase::requestTranslationForNode()
- BaseFlowTest::testUploadFileAndDownloadTranslation in tests/
src/ Functional/ BaseFlowTest.php - Test upload and download translation.
- ContextTest::testContextSendingByCron in tests/
src/ Functional/ ContextTest.php - Test context sending by cron.
- ContextTest::testManualContextSending in tests/
src/ Functional/ ContextTest.php - Test manual context sending.
- ContextTest::testOverrideContextOption in tests/
src/ Functional/ ContextTest.php - Test override context css class.
- ContextTest::testSilentSwitchingOff in tests/
src/ Functional/ ContextTest.php - Test context uploading with turned off "Silent switching mode" feature.
File
- tests/
src/ Functional/ SmartlingTestBase.php, line 194
Class
- SmartlingTestBase
- Basic tests for the Smartling translator.
Namespace
Drupal\Tests\tmgmt_smartling\FunctionalCode
protected function requestTranslationForNode($nid, $language, $translator) {
if (!is_array($nid)) {
$nid = [
$nid,
];
}
$api_wrapper = $translator
->getPlugin()
->getApiWrapper($translator
->getSettings());
$job_id = $api_wrapper
->createJob('Drupal TMGMT connector test ' . mt_rand(), '');
$batch_uid = $api_wrapper
->createBatch($job_id, FALSE);
$job = $this
->createJob($this->sourceLanguage, $language, 1, [
'label' => 'Job for ' . implode(', ', $nid),
'job_type' => Job::TYPE_NORMAL,
]);
$job
->set('settings', [
'batch_uid' => $batch_uid,
'batch_execute_on_job' => $job
->id(),
]);
$job->translator = $translator;
foreach ($nid as $item) {
$job
->addItem('content', 'node', $item);
}
$job
->setState(JobInterface::STATE_ACTIVE);
$job
->requestTranslation();
$api_wrapper
->cancelJob($job_id);
return $job;
}