You are here

public function LingotekConfigBulkFormTest::testClearJobIdsWithTMSUpdateWithAnError in Lingotek Translation 3.1.x

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

Tests clearing job ids with TMS update.

File

tests/src/Functional/Form/LingotekConfigBulkFormTest.php, line 869

Class

LingotekConfigBulkFormTest
Tests the config bulk management form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

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

  // I can init the upload of content.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/upload/node_type/article?destination=' . $basepath . '/admin/lingotek/config/manage');
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/upload/node_type/page?destination=' . $basepath . '/admin/lingotek/config/manage');
  $this
    ->clickLink('EN');
  $edit = [
    'table[article]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForAssignJobId('node_type'),
  ];
  $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[page]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForAssignJobId('node_type'),
  ];
  $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');

  // If we update the job ID with notification to the TMS, an update happens.
  \Drupal::state()
    ->set('lingotek.must_error_in_upload', TRUE);
  $edit = [
    'table[article]' => TRUE,
    'table[page]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForClearJobId('node_type'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->drupalPostForm(NULL, [
    'update_tms' => 1,
  ], 'Clear Job ID');
  $this
    ->assertText('The Job ID change submission for node_type Article failed. Please try again.');
  $this
    ->assertText('Job ID for some config failed to sync to the TMS.');

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

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