You are here

public function LingotekUserSettingsBulkTranslationTest::testEditedConfigTranslationUsingLinks in Lingotek Translation 8.2

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

Tests that a config can be translated using the links on the management page.

File

tests/src/Functional/LingotekUserSettingsBulkTranslationTest.php, line 150

Class

LingotekUserSettingsBulkTranslationTest
Tests translating user settings using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testEditedConfigTranslationUsingLinks() {

  // We need a config object with translations first.
  $this
    ->testUserSettingsTranslationUsingLinks();

  // Add a language so we can check that it's not marked as dirty if there are
  // no translations.
  ConfigurableLanguage::createFromLangcode('eu')
    ->setThirdPartySetting('lingotek', 'locale', 'eu_ES')
    ->save();

  // Add a language so we can check that it's not marked as for requesting if
  // it was already requested.
  ConfigurableLanguage::createFromLangcode('ko')
    ->setThirdPartySetting('lingotek', 'locale', 'ko_KR')
    ->save();

  // Edit the object
  $this
    ->drupalPostForm('/admin/config/people/accounts', [
    'anonymous' => 'Unknown user',
  ], t('Save configuration'));

  // Go to the bulk config management page.
  $this
    ->goToConfigBulkManagementForm();

  // Check the source status is edited.
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_EDITED);
  $this
    ->assertTargetStatus('ES', Lingotek::STATUS_PENDING);

  // Check the status is not edited for Vasque, but available to request
  // translation.
  $this
    ->assertNoTargetStatus('EU', Lingotek::STATUS_EDITED);
  $this
    ->assertTargetStatus('EU', Lingotek::STATUS_REQUEST);

  // Request korean, with outdated content available.
  $this
    ->clickLink('KO');
  $this
    ->assertText("Translation to ko_KR requested successfully");

  // Reupload the content.
  $this
    ->clickLink('EN', 3);
  $this
    ->assertText('Account settings has been updated.');

  // Korean should be marked as requested, so we can check target.
  $status = $this
    ->xpath("//a[contains(@class,'language-icon') and contains(@class, 'target-pending')  and contains(text(), 'KO')]");
  $this
    ->assertEqual(count($status), 1, 'Korean is requested, so we can still check the progress status of the translation');

  // Recheck status.
  $this
    ->clickLink('EN', 3);
  $this
    ->assertText('Account settings status checked successfully');

  // Check the translation after having been edited.
  // Check status of the Spanish translation.
  $edit = [
    'table[entity.user.admin_form]' => TRUE,
    $this
      ->getBulkOperationFormName() => 'check_translation:es',
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertText('Operations completed.');

  // Download the translation.
  $this
    ->clickLink('ES');
  $this
    ->assertText('Translation to es_MX downloaded successfully');
}