You are here

public function LingotekNodeBulkFormTest::testAssignJobIdsWithTMSUpdateWithADocumentArchivedError in Lingotek Translation 8.2

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

Tests that can we assign job ids with the bulk operation with TMS update.

File

tests/src/Functional/Form/LingotekNodeBulkFormTest.php, line 1147

Class

LingotekNodeBulkFormTest
Tests the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

public function testAssignJobIdsWithTMSUpdateWithADocumentArchivedError() {

  // Create a couple of nodes.
  $edit = [];
  $edit['title[0][value]'] = 'Llamas are cool';
  $edit['body[0][value]'] = 'Llamas are very cool';
  $edit['langcode[0][value]'] = 'en';
  $edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
  $this
    ->saveAndPublishNodeForm($edit);
  $edit['title[0][value]'] = 'Dogs are cool';
  $edit['body[0][value]'] = 'Dogs are very cool';
  $edit['langcode[0][value]'] = 'en';
  $edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
  $this
    ->saveAndPublishNodeForm($edit);
  $this
    ->goToContentBulkManagementForm();

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

  // There is no update, because there are no document ids.
  \Drupal::state()
    ->resetCache();
  $this
    ->assertNull(\Drupal::state()
    ->get('lingotek.uploaded_title'));
  $this
    ->assertNull(\Drupal::state()
    ->get('lingotek.uploaded_content'));
  $this
    ->assertNull(\Drupal::state()
    ->get('lingotek.uploaded_job_id'));

  // The job id is displayed.
  $this
    ->assertText('my_custom_job_id');

  // And the job id is used on upload.
  $this
    ->clickLink('EN');
  $this
    ->assertText('Node Llamas are cool has been uploaded.');

  // Check that the job id used was the right one.
  \Drupal::state()
    ->resetCache();
  $this
    ->assertIdentical(\Drupal::state()
    ->get('lingotek.uploaded_job_id'), 'my_custom_job_id');

  // If we update the job ID with notification to the TMS, an update happens.
  \Drupal::state()
    ->set('lingotek.must_document_archived_error_in_update', TRUE);

  // If we update the job ID with notification to the TMS, an update happens.
  $edit = [
    'table[1]' => TRUE,
    'table[2]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForAssignJobId('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $edit = [
    'job_id' => 'other_job_id',
    'update_tms' => 1,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Assign Job ID');
  $this
    ->assertText('Document node Llamas are cool has been archived. Please upload again.');
  $this
    ->assertText('Job ID for some content failed to sync to the TMS.');

  // There is no update.
  \Drupal::state()
    ->resetCache();
  $this
    ->assertEquals('my_custom_job_id', \Drupal::state()
    ->get('lingotek.uploaded_job_id'));
  $this
    ->assertText('my_custom_job_id');
  $this
    ->assertText('other_job_id');
}