You are here

public function LingotekNodeBulkFormTest::testAssignInvalidJobIdsWithTMSUpdate in Lingotek Translation 3.3.x

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

Tests that we cannot assign job ids with invalid chars.

File

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

Class

LingotekNodeBulkFormTest
Tests the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

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

  // 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, 'node');
  $this
    ->assertLingotekUploadLink(2, 'node');
  $this
    ->clickLink('EN');
  $edit = [
    'table[1]' => TRUE,
    'table[2]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForAssignJobId('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $edit = [
    'job_id' => 'my\\invalid\\id',
    'update_tms' => 1,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Assign Job ID');
  $this
    ->assertText('The job ID name cannot contain invalid chars as "/" or "\\".');

  // There is no update, because it's not valid.
  $this
    ->assertNull(\Drupal::state()
    ->get('lingotek.uploaded_job_id'));
  $edit = [
    'job_id' => 'my/invalid/id',
    'update_tms' => 1,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Assign Job ID');
  $this
    ->assertText('The job ID name cannot contain invalid chars as "/" or "\\".');

  // There is no update, because it's not valid.
  $this
    ->assertNull(\Drupal::state()
    ->get('lingotek.uploaded_job_id'));
}