You are here

public function ChineseBulkTranslationTest::testSystemSiteTranslationUsingLinks in Lingotek Translation 3.6.x

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

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

File

tests/src/Functional/ChineseBulkTranslationTest.php, line 116

Class

ChineseBulkTranslationTest
Tests translating into chinese locales.

Namespace

Drupal\Tests\lingotek\Functional

Code

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

  // This is a hack for avoiding writing different lingotek endpoint mocks.
  \Drupal::state()
    ->set('lingotek.uploaded_content_type', 'system.site');

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

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

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

  // And we cannot request yet a translation.
  $assert_session
    ->linkByHrefNotExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/zh_CN?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('EN', 1);
  $this
    ->assertText(t('System information 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/system.site_information_settings/system.site_information_settings?destination=' . $basepath . '/admin/lingotek/config/manage');

  // And we can already request a translation.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/zh_CN?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('EN', 1);
  $this
    ->assertText('System information status checked successfully');

  // Request the Chinese translation.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/zh_CN?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('ZH');
  $this
    ->assertText("Translation to zh_CN requested successfully");

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

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

  // Download the Chinese translation.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/download/system.site_information_settings/system.site_information_settings/zh_CN?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('ZH');
  $this
    ->assertText('Translation to zh_CN downloaded successfully');
  $this
    ->assertIdentical('zh_CN', \Drupal::state()
    ->get('lingotek.downloaded_locale'));

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