You are here

public function LingotekFieldBodyBulkTranslationTest::testTranslationDownloadWithUnrequestedLocales in Lingotek Translation 8.2

Same name and namespace in other branches
  1. 4.0.x tests/src/Functional/LingotekFieldBodyBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyBulkTranslationTest::testTranslationDownloadWithUnrequestedLocales()
  2. 3.0.x tests/src/Functional/LingotekFieldBodyBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyBulkTranslationTest::testTranslationDownloadWithUnrequestedLocales()
  3. 3.1.x tests/src/Functional/LingotekFieldBodyBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyBulkTranslationTest::testTranslationDownloadWithUnrequestedLocales()
  4. 3.2.x tests/src/Functional/LingotekFieldBodyBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyBulkTranslationTest::testTranslationDownloadWithUnrequestedLocales()
  5. 3.3.x tests/src/Functional/LingotekFieldBodyBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyBulkTranslationTest::testTranslationDownloadWithUnrequestedLocales()
  6. 3.4.x tests/src/Functional/LingotekFieldBodyBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyBulkTranslationTest::testTranslationDownloadWithUnrequestedLocales()
  7. 3.5.x tests/src/Functional/LingotekFieldBodyBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyBulkTranslationTest::testTranslationDownloadWithUnrequestedLocales()
  8. 3.6.x tests/src/Functional/LingotekFieldBodyBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyBulkTranslationTest::testTranslationDownloadWithUnrequestedLocales()
  9. 3.7.x tests/src/Functional/LingotekFieldBodyBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyBulkTranslationTest::testTranslationDownloadWithUnrequestedLocales()
  10. 3.8.x tests/src/Functional/LingotekFieldBodyBulkTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyBulkTranslationTest::testTranslationDownloadWithUnrequestedLocales()

Tests that unrequested locales are not marked as error when downloading all.

File

tests/src/Functional/LingotekFieldBodyBulkTranslationTest.php, line 1024

Class

LingotekFieldBodyBulkTranslationTest
Tests translating a field using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testTranslationDownloadWithUnrequestedLocales() {
  ConfigurableLanguage::createFromLangcode('de')
    ->setThirdPartySetting('lingotek', 'locale', 'de_DE')
    ->save();
  ConfigurableLanguage::createFromLangcode('it')
    ->setThirdPartySetting('lingotek', 'locale', 'it_IT')
    ->save();
  $this
    ->goToConfigBulkManagementForm('node_fields');
  $basepath = \Drupal::request()
    ->getBasePath();

  // I can init the upload of content.
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/config/upload/field_config/node.article.body?destination=' . $basepath . '/admin/lingotek/config/manage');
  $edit = [
    'table[node.article.body]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForUpload('node_fields'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical('en_US', \Drupal::state()
    ->get('lingotek.uploaded_locale'));

  // I can check current status.
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/config/check_upload/field_config/node.article.body?destination=' . $basepath . '/admin/lingotek/config/manage');
  $edit = [
    'table[node.article.body]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForCheckUpload('node_fields'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());

  // Request the Spanish translation.
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/config/request/field_config/node.article.body/es_MX?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('ES');
  $this
    ->assertText("Translation to es_MX requested successfully");
  $this
    ->assertIdentical('es_MX', \Drupal::state()
    ->get('lingotek.added_target_locale'));

  // Check status of the Spanish translation.
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/config/check_download/field_config/node.article.body/es_MX?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('ES');
  $this
    ->assertIdentical('es_MX', \Drupal::state()
    ->get('lingotek.checked_target_locale'));
  $this
    ->assertText("Translation to es_MX status checked successfully");

  // Download all the translations.
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/config/download/field_config/node.article.body/es_MX?destination=' . $basepath . '/admin/lingotek/config/manage');
  $edit = [
    'table[node.article.body]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForDownloadTranslations('node_fields'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());

  // The translations not requested shouldn't change its status.
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/config/request/field_config/node.article.body/de_DE?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/config/request/field_config/node.article.body/it_IT?destination=' . $basepath . '/admin/lingotek/config/manage');

  // They aren't marked as error.
  $this
    ->assertNoConfigTargetError('Body', 'DE', 'de_DE');
  $this
    ->assertNoConfigTargetError('Body', 'IT', 'it_IT');
}