You are here

protected function TmgmtExtensionSuitTestBase::requestBulkTranslation in TMGMT Extension Suite 8

Requests nodes for translation in a batch.

Parameters

array $nids:

array $targetLanguages:

$provider:

array $settings:

Throws

\Exception

4 calls to TmgmtExtensionSuitTestBase::requestBulkTranslation()
RequestBulkTranslationTest::testRequestBulkTranslation in src/Tests/RequestBulkTranslationTest.php
Test request bulk translation.
RequestBulkTranslationTest::testRequestBulkTranslationSkippingNodeInOneLanguage in src/Tests/RequestBulkTranslationTest.php
Test request bulk translation with conflicting item.
RequestBulkTranslationTest::testRequestBulkTranslationSkippingNodeInTwoLanguages in src/Tests/RequestBulkTranslationTest.php
Test request bulk translation with conflicting items.
RequestBulkTranslationTest::testRequestBulkTranslationValidation in src/Tests/RequestBulkTranslationTest.php
Test validation for bulk translation.

File

src/Tests/TmgmtExtensionSuitTestBase.php, line 107

Class

TmgmtExtensionSuitTestBase
Basic class for tmgmt extension module.

Namespace

Drupal\tmgmt_extension_suit\Tests

Code

protected function requestBulkTranslation(array $nids, array $targetLanguages, $provider = 'local', 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'));
  }
}