You are here

public function LingotekSystemSiteBulkTranslationTest::testCheckTranslationsWithDownloadedLocales in Lingotek Translation 8.2

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

Tests that current locales are not cleared when checking statuses.

File

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

Class

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

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testCheckTranslationsWithDownloadedLocales() {
  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.
  $this
    ->assertLinkByHref($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.
  $this
    ->assertLinkByHref($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.
  $this
    ->assertLinkByHref($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'));
  \Drupal::state()
    ->resetCache();

  // Request italian.
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/it_IT?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('IT');
  $this
    ->assertText("Translation to it_IT requested successfully");
  $this
    ->assertIdentical('it_IT', \Drupal::state()
    ->get('lingotek.added_target_locale'));

  // Check status of the Spanish translation.
  $this
    ->assertLinkByHref($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");
  \Drupal::state()
    ->resetCache();

  // Check status of the Italian translation.
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/config/check_download/system.site_information_settings/system.site_information_settings/it_IT?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('IT');
  $this
    ->assertIdentical('it_IT', \Drupal::state()
    ->get('lingotek.checked_target_locale'));
  $this
    ->assertText("Translation to it_IT checked successfully");

  // Download all the translations.
  $this
    ->assertLinkByHref($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());

  // They are marked with the right status.
  $this
    ->assertTargetStatus('ES', 'current');
  $this
    ->assertTargetStatus('IT', 'current');
  $this
    ->assertTargetStatus('DE', 'request');

  // We check all translations.
  \Drupal::state()
    ->set('lingotek.document_completion_statuses', [
    'es-ES' => 100,
    'it-IT' => 100,
  ]);
  $edit = [
    'table[system.site_information_settings]' => TRUE,
    $this
      ->getBulkOperationFormName() => 'check_translations',
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());

  // And statuses should remain the same.
  $this
    ->assertTargetStatus('ES', 'current');
  $this
    ->assertTargetStatus('IT', 'current');
  $this
    ->assertTargetStatus('DE', 'request');
}