You are here

public function LingotekNodeManageTranslationTabTest::testAssignJobIds in Lingotek Translation 3.3.x

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

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

File

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

Class

LingotekNodeManageTranslationTabTest
Tests translating a node using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testAssignJobIds() {

  // 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');
  $edit = [
    'table[node:1]' => TRUE,
    'table[taxonomy_term:1]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForAssignJobId('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $edit = [
    'job_id' => 'my_custom_job_id',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Assign Job ID');
  $this
    ->assertText('Job ID was assigned successfully.');

  // There is no upload.
  $this
    ->assertNull(\Drupal::state()
    ->get('lingotek.uploaded_title'));
  $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 without notification to the TMS, no update happens.
  $edit = [
    'table[node:1]' => TRUE,
    'table[taxonomy_term:1]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForAssignJobId('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $edit = [
    'job_id' => 'other_job_id',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Assign Job ID');
  $this
    ->assertText('Job ID was assigned successfully.');

  // There is no upload.
  \Drupal::state()
    ->resetCache();
  $this
    ->assertNotNull(\Drupal::state()
    ->get('lingotek.uploaded_title'));
  $this
    ->assertNotNull(\Drupal::state()
    ->get('lingotek.uploaded_content'));
  $this
    ->assertEquals('my_custom_job_id', \Drupal::state()
    ->get('lingotek.uploaded_job_id'));
}