You are here

public function LingotekConfigBulkFormTest::testJobIdOnUpdate in Lingotek Translation 3.6.x

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

Tests job id is uploaded on update.

File

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

Class

LingotekConfigBulkFormTest
Tests the config bulk management form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

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

  // Create a node type with automatic. This will trigger upload.
  $this
    ->drupalCreateContentType([
    'type' => 'banner',
    'name' => 'Banner',
  ]);
  $this
    ->drupalCreateContentType([
    'type' => 'book',
    'name' => 'Book',
  ]);
  $this
    ->drupalCreateContentType([
    'type' => 'ingredient',
    'name' => 'Ingredient',
  ]);
  $this
    ->drupalCreateContentType([
    'type' => 'recipe',
    'name' => 'Recipe',
  ]);
  $this
    ->goToConfigBulkManagementForm('node_type');

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

  // I can check the status of the upload. So next operation will perform an
  // update.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/check_upload/node_type/book?destination=' . $basepath . '/admin/lingotek/config/manage');
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/check_upload/node_type/recipe?destination=' . $basepath . '/admin/lingotek/config/manage');
  $edit = [
    'table[ingredient]' => TRUE,
    'table[recipe]' => TRUE,
    'table[book]' => TRUE,
    'table[banner]' => TRUE,
    'job_id' => 'my_custom_job_id',
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForUpload('node_type'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertEquals('en_US', \Drupal::state()
    ->get('lingotek.uploaded_locale'));
  $this
    ->assertEquals('my_custom_job_id', \Drupal::state()
    ->get('lingotek.uploaded_job_id'));

  /** @var \Drupal\lingotek\Entity\LingotekConfigMetadata[] $metadatas */
  $metadatas = LingotekConfigMetadata::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');
}