You are here

public function LingotekSystemSiteBulkTranslationTest::testTranslationDownloadWithUnrequestedLocales in Lingotek Translation 3.6.x

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

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

File

tests/src/Functional/LingotekSystemSiteBulkTranslationTest.php, line 982

Class

LingotekSystemSiteBulkTranslationTest
Tests translating a config object using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

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

  // I can init the upload of content.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/upload/system.site_information_settings/system.site_information_settings?destination=' . $basepath . '/admin/lingotek/config/manage');
  $edit = [
    'table[system.site_information_settings]' => TRUE,
    $this
      ->getBulkOperationFormName() => 'upload',
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical('en_US', \Drupal::state()
    ->get('lingotek.uploaded_locale'));

  // I can check current status.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/check_upload/system.site_information_settings/system.site_information_settings?destination=' . $basepath . '/admin/lingotek/config/manage');
  $edit = [
    'table[system.site_information_settings]' => TRUE,
    $this
      ->getBulkOperationFormName() => 'check_upload',
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());

  // Request the Spanish translation.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/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.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/check_download/system.site_information_settings/system.site_information_settings/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 checked successfully");

  // Download all the translations.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/download/system.site_information_settings/system.site_information_settings/es_MX?destination=' . $basepath . '/admin/lingotek/config/manage');
  $edit = [
    'table[system.site_information_settings]' => TRUE,
    $this
      ->getBulkOperationFormName() => 'download',
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());

  // The translations not requested shouldn't change its status.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/de_DE?destination=' . $basepath . '/admin/lingotek/config/manage');
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/it_IT?destination=' . $basepath . '/admin/lingotek/config/manage');

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