You are here

public function LingotekEntityTestBulkTranslationTest::testEntityTestTranslationUsingLinks in Lingotek Translation 3.6.x

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

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

File

tests/src/Functional/LingotekEntityTestBulkTranslationTest.php, line 70

Class

LingotekEntityTestBulkTranslationTest
Tests translating the entity test using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testEntityTestTranslationUsingLinks() {

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

  // Create a entity_test_mul.
  $edit = [];
  $edit['name[0][value]'] = 'Llamas are cool';
  $edit['field_test_text[0][value]'] = 'Llamas are very cool';
  $edit['langcode[0][value]'] = 'en';
  $edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
  $this
    ->drupalPostForm('/entity_test_mul/add/entity_test_mul', $edit, t('Save'));
  $this
    ->goToContentBulkManagementForm('entity_test_mul');

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

  // And we cannot request yet a translation.
  $this
    ->assertNoLingotekRequestTranslationLink('es_MX', 'dummy-document-hash-id', 'entity_test_mul');
  $this
    ->clickLink('EN');
  $this
    ->assertText('Entity_test_mul 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('dummy-document-hash-id', 'entity_test_mul');

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

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

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

  // Download the Spanish translation.
  $this
    ->assertLingotekDownloadTargetLink('es_MX', 'dummy-document-hash-id', 'entity_test_mul');
  $this
    ->clickLink('ES');
  $this
    ->assertText('The translation of entity_test_mul 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');
}