You are here

public function LingotekContentTypeBulkDisabledTargetOverrideTranslationTest::xxxtestFieldBodyTranslationUsingActions in Lingotek Translation 3.6.x

Same name and namespace in other branches
  1. 3.5.x tests/src/Functional/LingotekContentTypeBulkDisabledTargetOverrideTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekContentTypeBulkDisabledTargetOverrideTranslationTest::xxxtestFieldBodyTranslationUsingActions()

Tests that a field can be translated using the actions on the management page.

File

tests/src/Functional/LingotekContentTypeBulkDisabledTargetOverrideTranslationTest.php, line 101

Class

LingotekContentTypeBulkDisabledTargetOverrideTranslationTest
Tests translating a content type using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function xxxtestFieldBodyTranslationUsingActions() {
  $assert_session = $this
    ->assertSession();
  $basepath = \Drupal::request()
    ->getBasePath();
  $this
    ->goToConfigBulkManagementForm('node_type');

  // 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_MX?destination=' . $basepath . '/admin/lingotek/config/manage');
  $assert_session
    ->linkByHrefNotExists($basepath . '/admin/lingotek/config/request/node_type/article/ca_ES?destination=' . $basepath . '/admin/lingotek/config/manage');

  // I can init the upload of content.
  $edit = [
    'table[article]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForUpload('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical('en_US', \Drupal::state()
    ->get('lingotek.uploaded_locale'));
  $this
    ->assertText('Operations completed.');
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/request/node_type/article/es_MX?destination=' . $basepath . '/admin/lingotek/config/manage');
  $assert_session
    ->linkByHrefNotExists($basepath . '/admin/lingotek/config/request/node_type/article/ca_ES?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->assertTargetStatus('es', Lingotek::STATUS_REQUEST);
  $this
    ->assertTargetStatus('ca', Lingotek::STATUS_DISABLED);

  // Request the disabled target translation.
  $edit = [
    'table[article]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForRequestTranslation('ca', 'node_type'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical(NULL, \Drupal::state()
    ->get('lingotek.added_target_locale'));
  $this
    ->assertIdentical(NULL, \Drupal::state()
    ->get('lingotek.requested_locales'));
  $this
    ->assertText('Operations completed.');
  $this
    ->assertTargetStatus('es', Lingotek::STATUS_REQUEST);
  $this
    ->assertTargetStatus('ca', Lingotek::STATUS_DISABLED);

  // Check status of the disabled target translation.
  $assert_session
    ->linkByHrefNotExists($basepath . '/admin/lingotek/config/check_download/node_type/article/ca_ES?destination=' . $basepath . '/admin/lingotek/config/manage');
  $edit = [
    'table[article]' => TRUE,
    $this
      ->getBulkOperationFormName() => 'check_translation:ca',
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical(NULL, \Drupal::state()
    ->get('lingotek.checked_target_locale'));
  $this
    ->assertTargetStatus('es', Lingotek::STATUS_REQUEST);
  $this
    ->assertTargetStatus('ca', Lingotek::STATUS_DISABLED);

  // Download the Catalan translation.
  $assert_session
    ->linkByHrefNotExists($basepath . '/admin/lingotek/config/download/node_type/article/ca_ES?destination=' . $basepath . '/admin/lingotek/config/manage');
  $edit = [
    'table[article]' => TRUE,
    $this
      ->getBulkOperationFormName() => 'download:ca',
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical(NULL, \Drupal::state()
    ->get('lingotek.downloaded_locale'));
  $this
    ->assertTargetStatus('es', Lingotek::STATUS_REQUEST);
  $this
    ->assertTargetStatus('ca', Lingotek::STATUS_DISABLED);
}