You are here

public function LingotekNodeBulkTranslationTest::testEditedNodeTranslationUsingLinks in Lingotek Translation 3.0.x

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

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

File

tests/src/Functional/LingotekNodeBulkTranslationTest.php, line 524

Class

LingotekNodeBulkTranslationTest
Tests translating a node using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testEditedNodeTranslationUsingLinks() {

  // We need a node with translations first.
  $this
    ->testNodeTranslationUsingLinks();

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

  // 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 node.
  $edit = [];
  $edit['title[0][value]'] = 'Llamas are cool EDITED';
  $edit['body[0][value]'] = 'Llamas are very cool EDITED';
  $edit['langcode[0][value]'] = 'en';
  $edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
  $this
    ->saveAndKeepPublishedThisTranslationNodeForm($edit, 1);

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

  // 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("Locale 'ko_KR' was added as a translation target for node Llamas are cool EDITED.");

  // Reupload the content.
  $this
    ->clickLink('EN');
  $this
    ->assertText('Node Llamas are cool EDITED has been updated.');

  // Korean should be marked as requested, so we can check target.
  $this
    ->assertTargetStatus('KO', 'pending');

  // Recheck status.
  $this
    ->clickLink('EN');
  $this
    ->assertText('The import for node Llamas are cool EDITED is complete.');

  // Korean should still be marked as requested, so we can check target.
  $this
    ->assertTargetStatus('KO', 'pending');

  // Check the translation after having been edited.
  $key = $this
    ->getBulkSelectionKey('en', 1);
  $edit = [
    $key => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForCheckTranslations('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertTargetStatus('ES', 'ready');

  // Download the translation.
  $this
    ->clickLink('ES');
  $this
    ->assertText('The translation of node Llamas are cool EDITED into es_MX has been downloaded.');
}