You are here

public function LingotekContentTypeBulkLocaleTranslationTest::testSystemSiteTranslationUsingLinks in Lingotek Translation 3.5.x

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

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

File

tests/src/Functional/LingotekContentTypeBulkLocaleTranslationTest.php, line 49

Class

LingotekContentTypeBulkLocaleTranslationTest
Tests translating a config entity into locales using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

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

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

  // Go to the bulk config management page.
  $this
    ->goToConfigBulkManagementForm('node_type');
  $basepath = \Drupal::request()
    ->getBasePath();

  // Clicking English must init the upload of content.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/upload/node_type/article?destination=' . $basepath . '/admin/lingotek/config/manage');

  // And we cannot request yet a translation.
  $assert_session
    ->linkByHrefNotExists($basepath . '/admin/lingotek/config/request/node_type/article/es_ES?destination=' . $basepath . '/admin/lingotek/config/manage');
  $assert_session
    ->linkByHrefNotExists($basepath . '/admin/lingotek/config/request/node_type/article/es_AR?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('EN');
  $this
    ->assertText(t('Article uploaded successfully'));
  $this
    ->assertIdentical('en_US', \Drupal::state()
    ->get('lingotek.uploaded_locale'));

  // There is a link for checking status.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/check_upload/node_type/article?destination=' . $basepath . '/admin/lingotek/config/manage');

  // And we can already request a translation.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/request/node_type/article/es_ES?destination=' . $basepath . '/admin/lingotek/config/manage');
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/request/node_type/article/es_AR?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('EN');
  $this
    ->assertText('Article status checked successfully');

  // Request the German (AT) translation.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/request/node_type/article/de_AT?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('DE-AT');
  $this
    ->assertText("Translation to de_AT requested successfully");

  // Check that the requested locale is the right one.
  $this
    ->assertIdentical('de_AT', \Drupal::state()
    ->get('lingotek.added_target_locale'));
  \Drupal::state()
    ->resetCache();

  // Request the Spanish translation.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/request/node_type/article/es_ES?destination=' . $basepath . '/admin/lingotek/config/manage');
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/request/node_type/article/es_AR?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('ES');
  $this
    ->assertText("Translation to es_AR requested successfully");

  // Check that the requested locale is the right one.
  $this
    ->assertIdentical('es_AR', \Drupal::state()
    ->get('lingotek.added_target_locale'));

  // Check status of the Spanish translation.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/check_download/node_type/article/es_AR?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('ES');
  $this
    ->assertIdentical('es_AR', \Drupal::state()
    ->get('lingotek.checked_target_locale'));
  $this
    ->assertText("Translation to es_AR status checked successfully");

  // Download the Spanish translation.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/download/node_type/article/es_AR?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('ES');
  $this
    ->assertText('Translation to es_AR downloaded successfully');
  $this
    ->assertIdentical('es_AR', \Drupal::state()
    ->get('lingotek.downloaded_locale'));

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

  // Check that the order of target languages is always alphabetical.
  $target_links = $this
    ->xpath("//a[contains(@class,'language-icon')]");
  $this
    ->assertEqual(count($target_links), 3, 'The three languages appear as targets');
  $this
    ->assertEqual('DE-AT', $target_links[0]
    ->getHtml(), 'DE-AT is the first language');
  $this
    ->assertEqual('ES', $target_links[1]
    ->getHtml(), 'ES is the second language');
  $this
    ->assertEqual('ES-ES', $target_links[2]
    ->getHtml(), 'ES-ES is the third language');
}