You are here

public function LingotekNodeWithParagraphsManageTranslationTabTest::testNodeTranslationUsingLinks in Lingotek Translation 3.8.x

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

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

File

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

Class

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

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testNodeTranslationUsingLinks() {
  $assert_session = $this
    ->assertSession();

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

  // 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 translations tab is in the node.
  $this
    ->drupalGet('node/1');
  $this
    ->clickLink('Manage Translations');
  $assert_session
    ->elementContains('css', 'table#edit-table', 'Llamas are cool');

  // Assert embedded are listed on the embedded table.
  $assert_session
    ->elementNotContains('css', 'table#edit-table', 'Image + Text');
  $assert_session
    ->elementContains('css', 'details#edit-related table', 'Image + Text');

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

  // And we cannot request yet a translation.
  $this
    ->assertNoLingotekRequestTranslationLink('es_MX');
  $this
    ->clickLink('EN');
  $this
    ->assertText('Node Llamas are cool has been uploaded.');
  $this
    ->assertIdentical('en_US', \Drupal::state()
    ->get('lingotek.uploaded_locale'));

  // There is a link for checking status.
  $this
    ->assertLingotekCheckSourceStatusLink();

  // And we can already request a translation.
  $this
    ->assertLingotekRequestTranslationLink('es_MX');
  $this
    ->clickLink('EN');
  $this
    ->assertText('The import for node Llamas are cool is complete.');

  // Request the Spanish translation.
  $this
    ->assertLingotekRequestTranslationLink('es_MX');
  $this
    ->clickLink('ES');
  $this
    ->assertText("Locale 'es_MX' was added as a translation target for node Llamas are cool.");
  $this
    ->assertIdentical('es_MX', \Drupal::state()
    ->get('lingotek.added_target_locale'));

  // Check status of the Spanish translation.
  $this
    ->assertLingotekCheckTargetStatusLink('es_MX');
  $this
    ->clickLink('ES');
  $this
    ->assertIdentical('es_MX', \Drupal::state()
    ->get('lingotek.checked_target_locale'));
  $this
    ->assertText('The es_MX translation for node Llamas are cool is ready for download.');

  // Download the Spanish translation.
  $this
    ->assertLingotekDownloadTargetLink('es_MX');
  $this
    ->clickLink('ES');
  $this
    ->assertText('The translation of node Llamas are cool into es_MX has been downloaded.');
  $this
    ->assertIdentical('es_MX', \Drupal::state()
    ->get('lingotek.downloaded_locale'));

  // Now the link is to the workbench, and it opens in a new tab.
  $this
    ->assertLingotekWorkbenchLink('es_MX', 'dummy-document-hash-id', 'ES');
}