You are here

public function LingotekConfigBulkFormTest::testJobIdFilter 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::testJobIdFilter()
  2. 4.0.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testJobIdFilter()
  3. 3.0.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testJobIdFilter()
  4. 3.1.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testJobIdFilter()
  5. 3.2.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testJobIdFilter()
  6. 3.3.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testJobIdFilter()
  7. 3.4.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testJobIdFilter()
  8. 3.5.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testJobIdFilter()
  9. 3.7.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testJobIdFilter()
  10. 3.8.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testJobIdFilter()

Tests that the bulk management filtering works correctly.

File

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

Class

LingotekConfigBulkFormTest
Tests the config bulk management form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

public function testJobIdFilter() {
  $assert_session = $this
    ->assertSession();
  \Drupal::configFactory()
    ->getEditable('lingotek.settings')
    ->set('translate.config.node_type.profile', 'manual')
    ->save();
  $basepath = \Drupal::request()
    ->getBasePath();
  $node_types = [];

  // See https://www.drupal.org/project/drupal/issues/2925290.
  $indexes = "ABCDEFGHIJKLMNOPQ";

  // Create some nodes.
  for ($i = 1; $i < 10; $i++) {
    $node_types[$i] = $this
      ->drupalCreateContentType([
      'type' => 'content_type_' . $i,
      'name' => 'Content Type ' . $indexes[$i],
    ]);
  }
  $this
    ->goToConfigBulkManagementForm('node_type');
  $this
    ->assertNoText('No content available');

  // After we filter by an unexisting job, there is no content and no rows.
  $edit = [
    'filters[wrapper][job]' => 'this job does not exist',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
  $this
    ->assertText('No content available');

  // After we reset, we get back to having all the content.
  $this
    ->drupalPostForm(NULL, [], 'Reset');
  $this
    ->goToConfigBulkManagementForm('node_type');
  foreach (range(1, 9) as $j) {
    $this
      ->assertText('Content Type ' . $indexes[$j]);
  }

  // I can init the upload of content.
  $assert_session
    ->linkByHrefExists($basepath . '/admin/lingotek/config/upload/node_type/article?destination=' . $basepath . '/admin/lingotek/config/manage');
  $edit = [
    'table[content_type_2]' => TRUE,
    'table[content_type_4]' => TRUE,
    'table[content_type_6]' => TRUE,
    'table[content_type_8]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForUpload('node_type'),
    'job_id' => 'even numbers',
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $edit = [
    'table[content_type_1]' => TRUE,
    'table[content_type_2]' => TRUE,
    'table[content_type_3]' => TRUE,
    'table[content_type_5]' => TRUE,
    'table[content_type_7]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForUpload('node_type'),
    'job_id' => 'prime numbers',
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());

  // After we filter by prime, there is no pager and the rows
  // selected are the ones expected.
  $edit = [
    'filters[wrapper][job]' => 'prime',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
  foreach ([
    1,
    2,
    3,
    5,
    7,
  ] as $j) {
    $this
      ->assertText('Content Type ' . $indexes[$j]);
  }
  $this
    ->assertNoText('Content Type ' . $indexes[4]);
  $this
    ->assertNoText('Content Type ' . $indexes[6]);

  // After we filter by even, there is no pager and the rows selected are the
  // ones expected.
  $edit = [
    'filters[wrapper][job]' => 'even',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
  foreach ([
    4,
    6,
    8,
  ] as $j) {
    $this
      ->assertText('Content Type ' . $indexes[$j]);
  }
  $this
    ->assertNoText('Content Type ' . $indexes[5]);

  // After we reset, we get back to having all the content.
  $this
    ->drupalPostForm(NULL, [], 'Reset');
  $this
    ->goToConfigBulkManagementForm('node_type');
  foreach (range(1, 9) as $j) {
    $this
      ->assertText('Content Type ' . $indexes[$j]);
  }
}