You are here

public function LingotekNodeManageTranslationTabTest::testClearJobIdsWithTMSUpdate in Lingotek Translation 3.5.x

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

Tests clearing job ids with TMS update.

File

tests/src/Functional/LingotekNodeManageTranslationTabTest.php, line 751

Class

LingotekNodeManageTranslationTabTest
Tests translating a node using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testClearJobIdsWithTMSUpdate() {

  // Create a couple of content.
  $edit = [];
  $edit['title[0][value]'] = 'Llamas are cool';
  $edit['body[0][value]'] = 'Llamas are very cool';
  $edit['langcode[0][value]'] = 'en';
  $edit['field_tags[target_id]'] = implode(',', [
    'Camelid',
    'Herbivorous',
  ]);
  $edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
  $this
    ->saveAndPublishNodeForm($edit);
  $this
    ->goToContentBulkManagementForm();

  // I can init the upload of content.
  $this
    ->assertLingotekUploadLink(1, 'node');
  $this
    ->assertLingotekUploadLink(1, 'taxonomy_term', NULL, 'node');
  $this
    ->clickLink('EN');
  $edit = [
    'table[node:1]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForAssignJobId('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $edit = [
    'job_id' => 'my_custom_job_id_1',
    'update_tms' => 1,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Assign Job ID');
  $this
    ->assertText('Job ID was assigned successfully.');
  $edit = [
    'table[taxonomy_term:1]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForAssignJobId('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $edit = [
    'job_id' => 'my_custom_job_id_2',
    'update_tms' => 1,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Assign Job ID');
  $this
    ->assertText('Job ID was assigned successfully.');

  // The job id is displayed.
  $this
    ->assertText('my_custom_job_id_1');
  $this
    ->assertText('my_custom_job_id_2');
  $edit = [
    'table[node:1]' => TRUE,
    'table[taxonomy_term:1]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForClearJobId('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->drupalPostForm(NULL, [
    'update_tms' => 1,
  ], 'Clear Job ID');
  $this
    ->assertText('Job ID was cleared successfully.');

  // There is an update with empty job id.
  \Drupal::state()
    ->resetCache();
  $this
    ->assertEquals('', \Drupal::state()
    ->get('lingotek.uploaded_job_id'));

  // The job id is gone.
  $this
    ->assertNoText('my_custom_job_id_1');
  $this
    ->assertNoText('my_custom_job_id_2');
}