You are here

public function LingotekNodeWithParagraphsManageTranslationTabTest::testNodeTranslationUsingActions in Lingotek Translation 8.2

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

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

File

tests/src/Functional/LingotekNodeWithParagraphsManageTranslationTabTest.php, line 146

Class

LingotekNodeWithParagraphsManageTranslationTabTest
Tests translating a node with paragraphs using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testNodeTranslationUsingActions() {

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);

  // Add a language.
  ConfigurableLanguage::createFromLangcode('de')
    ->setThirdPartySetting('lingotek', 'locale', 'de_AT')
    ->save();

  // Add paragraphed content.
  $this
    ->drupalGet('node/add/paragraphed_content_demo');
  $this
    ->drupalPostForm(NULL, NULL, t('Add Image + Text'));
  $edit = [];
  $edit['title[0][value]'] = 'Llamas are cool';
  $edit['langcode[0][value]'] = 'en';
  $edit['field_paragraphs_demo[0][subform][field_text_demo][0][value]'] = 'Llamas are very cool';
  $edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
  $this
    ->saveAndPublishNodeForm($edit, NULL);

  // Login as translation manager.
  $this
    ->drupalLogin($this->translationManagerUser);

  // Check that the manage tranlsations tab is in the node.
  $this
    ->drupalGet('node/1');
  $this
    ->clickLink('Manage Translations');
  $this
    ->assertText('Llamas are cool');
  $this
    ->assertText('Image + Text');

  // I can init the upload of content.
  $this
    ->assertLingotekUploadLink();
  $edit = [
    'table[node:1]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForUpload('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical('en_US', \Drupal::state()
    ->get('lingotek.uploaded_locale'));

  // I can check current status.
  $this
    ->assertLingotekCheckSourceStatusLink();
  $edit = [
    'table[node:1]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForCheckUpload('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());

  // Request the German (AT) translation.
  $this
    ->assertLingotekRequestTranslationLink('de_AT');
  $edit = [
    'table[node:1]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForRequestTranslation('de', 'node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical('de_AT', \Drupal::state()
    ->get('lingotek.added_target_locale'));

  // Check status of the Spanish translation.
  $this
    ->assertLingotekCheckTargetStatusLink('de_AT');
  $edit = [
    'table[node:1]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForCheckTranslation('de', 'node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical('de_AT', \Drupal::state()
    ->get('lingotek.checked_target_locale'));

  // Download the Spanish translation.
  $this
    ->assertLingotekDownloadTargetLink('de_AT');
  $edit = [
    'table[node:1]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForDownloadTranslation('de', 'node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical('de_AT', \Drupal::state()
    ->get('lingotek.downloaded_locale'));

  // Now the link is to the workbench, and it opens in a new tab.
  $this
    ->assertLingotekWorkbenchLink('de_AT');
}