You are here

public function LingotekNodeBulkDisabledTargetOverrideTranslationTest::testNodeTranslationUsingActionsForMultipleLocales in Lingotek Translation 3.6.x

Same name and namespace in other branches
  1. 4.0.x tests/src/Functional/LingotekNodeBulkDisabledTargetOverrideTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkDisabledTargetOverrideTranslationTest::testNodeTranslationUsingActionsForMultipleLocales()
  2. 3.5.x tests/src/Functional/LingotekNodeBulkDisabledTargetOverrideTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkDisabledTargetOverrideTranslationTest::testNodeTranslationUsingActionsForMultipleLocales()
  3. 3.7.x tests/src/Functional/LingotekNodeBulkDisabledTargetOverrideTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkDisabledTargetOverrideTranslationTest::testNodeTranslationUsingActionsForMultipleLocales()
  4. 3.8.x tests/src/Functional/LingotekNodeBulkDisabledTargetOverrideTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeBulkDisabledTargetOverrideTranslationTest::testNodeTranslationUsingActionsForMultipleLocales()

Tests that a node can be translated using the actions on the management page for multiple locales.

File

tests/src/Functional/LingotekNodeBulkDisabledTargetOverrideTranslationTest.php, line 211

Class

LingotekNodeBulkDisabledTargetOverrideTranslationTest
Tests translating a node using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testNodeTranslationUsingActionsForMultipleLocales() {

  // Create a node.
  $edit = [];
  $edit['title[0][value]'] = 'Llamas are cool';
  $edit['body[0][value]'] = 'Llamas are very cool';
  $edit['langcode[0][value]'] = 'en';
  $edit['lingotek_translation_management[lingotek_translation_profile]'] = 'profile_with_disabled_targets';
  $this
    ->saveAndPublishNodeForm($edit);
  $this
    ->goToContentBulkManagementForm();

  // Clicking English must init the upload of content.
  $this
    ->assertLingotekUploadLink();

  // And we cannot request yet a translation.
  $this
    ->assertNoLingotekRequestTranslationLink('ca_ES');
  $this
    ->assertNoLingotekRequestTranslationLink('es_MX');
  $key = $this
    ->getBulkSelectionKey('en', 1);
  $edit = [
    $key => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForUpload('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical('en_US', \Drupal::state()
    ->get('lingotek.uploaded_locale'));
  $this
    ->assertText('Operations completed.');

  // There is a link for checking status.
  $this
    ->assertLingotekCheckSourceStatusLink();
  $key = $this
    ->getBulkSelectionKey('en', 1);
  $edit = [
    $key => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForCheckUpload('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical('en_US', \Drupal::state()
    ->get('lingotek.uploaded_locale'));
  $this
    ->assertText('Operations completed.');
  $this
    ->assertNoLingotekRequestTranslationLink('ca_ES');
  $this
    ->assertLingotekRequestTranslationLink('es_MX');
  $this
    ->assertTargetStatus('es', Lingotek::STATUS_REQUEST);
  $this
    ->assertTargetStatus('ca', Lingotek::STATUS_DISABLED);

  // Request the disabled target translation.
  $key = $this
    ->getBulkSelectionKey('en', 1);
  $edit = [
    $key => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForRequestTranslations('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical([
    'dummy-document-hash-id' => [
      'es_MX',
    ],
  ], \Drupal::state()
    ->get('lingotek.requested_locales'));
  $this
    ->assertText('Operations completed.');
  $this
    ->assertTargetStatus('es', Lingotek::STATUS_PENDING);
  $this
    ->assertTargetStatus('ca', Lingotek::STATUS_DISABLED);

  // Check status of the disabled target translation.
  $this
    ->assertNoLingotekCheckTargetStatusLink('ca_ES');
  $key = $this
    ->getBulkSelectionKey('en', 1);
  $edit = [
    $key => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForCheckTranslations('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical(NULL, \Drupal::state()
    ->get('lingotek.checked_target_locale'));
  $this
    ->assertTargetStatus('es', Lingotek::STATUS_READY);
  $this
    ->assertTargetStatus('ca', Lingotek::STATUS_DISABLED);

  // Download the Catalan translation.
  $this
    ->assertNoLingotekDownloadTargetLink('ca_ES');
  $key = $this
    ->getBulkSelectionKey('en', 1);
  $edit = [
    $key => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForDownloadTranslations('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical('es_MX', \Drupal::state()
    ->get('lingotek.downloaded_locale'));
  $this
    ->assertTargetStatus('es', Lingotek::STATUS_CURRENT);
  $this
    ->assertTargetStatus('ca', Lingotek::STATUS_DISABLED);
}