protected function TmgmtExtensionSuitTestBase::requestBulkTranslation in TMGMT Extension Suite 8.3
Same name and namespace in other branches
- 8.2 tests/src/Functional/TmgmtExtensionSuitTestBase.php \Drupal\Tests\tmgmt_extension_suit\Functional\TmgmtExtensionSuitTestBase::requestBulkTranslation()
Requests nodes for translation in a batch.
Parameters
array $nids: Node ids.
array $targetLanguages: Target locale.
string $provider: Provider type.
array $settings: Provider settings.
Throws
\Exception
File
- tests/
src/ Functional/ TmgmtExtensionSuitTestBase.php, line 124
Class
- TmgmtExtensionSuitTestBase
- Basic class for tmgmt extension module.
Namespace
Drupal\Tests\tmgmt_extension_suit\FunctionalCode
protected function requestBulkTranslation(array $nids, array $targetLanguages, $provider = 'tes_local_test', array $settings = []) {
// Request nodes for translation.
$data = [];
foreach ($nids as $nid) {
$data["items[{$nid}]"] = "item[{$nid}]";
}
$this
->drupalPostForm('admin/tmgmt/sources', $data, t('Request translation in a batch'));
if (!empty($targetLanguages)) {
$new_data = [];
foreach ($targetLanguages as $targetLanguage) {
$new_data["target_language[{$targetLanguage}]"] = $targetLanguage;
}
$new_data['translator'] = $provider;
foreach ($settings as $setting => $value) {
$new_data[$setting] = $value;
}
$this
->drupalPostForm(NULL, $new_data, t('Request translation'));
}
}