You are here

public function LingotekNodeBulkFormTest::testJobIdOnUpdate in Lingotek Translation 3.1.x

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

Tests job id is uploaded on update.

File

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

Class

LingotekNodeBulkFormTest
Tests the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

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

  // Create a node with automatic. This will trigger upload.
  $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]'] = 'automatic';
  $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]'] = 'automatic';
  $this
    ->saveAndPublishNodeForm($edit);
  $this
    ->goToContentBulkManagementForm();

  /** @var \Drupal\lingotek\Entity\LingotekContentMetadata[] $metadatas */
  $metadatas = LingotekContentMetadata::loadMultiple();
  foreach ($metadatas as $metadata) {
    $this
      ->assertNull($metadata
      ->getJobId(), 'There was no job id to save along with metadata.');
  }

  // I can check the status of the upload. So next operation will perform an
  // update.
  $this
    ->assertLingotekCheckSourceStatusLink('dummy-document-hash-id');
  $this
    ->assertLingotekCheckSourceStatusLink('dummy-document-hash-id-1');
  $edit = [
    'table[1]' => TRUE,
    'table[2]' => TRUE,
    'job_id' => 'my_custom_job_id',
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForUpload('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical('en_US', \Drupal::state()
    ->get('lingotek.uploaded_locale'));
  $this
    ->assertIdentical('my_custom_job_id', \Drupal::state()
    ->get('lingotek.uploaded_job_id'));

  /** @var \Drupal\lingotek\Entity\LingotekContentMetadata[] $metadatas */
  $metadatas = LingotekContentMetadata::loadMultiple();
  foreach ($metadatas as $metadata) {
    $this
      ->assertEquals('my_custom_job_id', $metadata
      ->getJobId(), 'The job id was saved along with metadata.');
  }

  // The column for Job ID exists and there are values.
  $this
    ->assertText('Job ID');
  $this
    ->assertText('my_custom_job_id');
}