You are here

public function LingotekNodeBulkFormWithContentModerationTest::testContentStateFilter in Lingotek Translation 3.6.x

Same name and namespace in other branches
  1. 4.0.x tests/src/Functional/Form/LingotekNodeBulkFormWithContentModerationTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithContentModerationTest::testContentStateFilter()
  2. 3.4.x tests/src/Functional/Form/LingotekNodeBulkFormWithContentModerationTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithContentModerationTest::testContentStateFilter()
  3. 3.5.x tests/src/Functional/Form/LingotekNodeBulkFormWithContentModerationTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithContentModerationTest::testContentStateFilter()
  4. 3.7.x tests/src/Functional/Form/LingotekNodeBulkFormWithContentModerationTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithContentModerationTest::testContentStateFilter()
  5. 3.8.x tests/src/Functional/Form/LingotekNodeBulkFormWithContentModerationTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithContentModerationTest::testContentStateFilter()

Tests if content state filter works correctly

File

tests/src/Functional/Form/LingotekNodeBulkFormWithContentModerationTest.php, line 63

Class

LingotekNodeBulkFormWithContentModerationTest
Tests the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

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

  // Create a node.
  $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
    ->saveAsNewDraftNodeForm($edit);

  // Go to the bulk management form.
  $this
    ->goToContentBulkManagementForm();
  $assert_session
    ->optionExists('filters[advanced_options][content_state]', 'All');
  $assert_session
    ->optionExists('filters[advanced_options][content_state]', 'archived');
  $assert_session
    ->optionExists('filters[advanced_options][content_state]', 'published');
  $assert_session
    ->optionExists('filters[advanced_options][content_state]', 'draft');

  // After we filter by "draft", there is no pager and the rows
  // selected are the ones expected.
  $update = [
    'filters[advanced_options][content_state]' => 'draft',
  ];
  $this
    ->drupalPostForm(NULL, $update, 'edit-filters-actions-submit');
  $assert_session
    ->linkExists('Llamas are cool');
  $this
    ->assertFieldByName('filters[advanced_options][content_state]', 'draft', 'The value is retained in the filter.');

  // Change the content moderation state to published
  $this
    ->saveAndKeepPublishedNodeForm($edit, 1);
  $this
    ->goToContentBulkManagementForm();
  $update = [
    'filters[advanced_options][content_state]' => 'published',
  ];
  $this
    ->drupalPostForm(NULL, $update, 'edit-filters-actions-submit');
  $assert_session
    ->linkExists('Llamas are cool');
  $this
    ->assertFieldByName('filters[advanced_options][content_state]', 'published', 'The value is retained in the filter.');

  // Change the content moderation state to archived
  $this
    ->saveAndArchiveNodeForm($edit, 1);
  $this
    ->goToContentBulkManagementForm();
  $update = [
    'filters[advanced_options][content_state]' => 'archived',
  ];
  $this
    ->drupalPostForm(NULL, $update, 'edit-filters-actions-submit');
  $assert_session
    ->linkExists('Llamas are cool');
  $this
    ->assertFieldByName('filters[advanced_options][content_state]', 'archived', 'The value is retained in the filter.');
  $update = [
    'filters[advanced_options][content_state]' => 'published',
  ];
  $this
    ->drupalPostForm(NULL, $update, 'edit-filters-actions-submit');

  // Make sure the document does not show up when we filter by published and the document is archived
  $assert_session
    ->linkNotExists('Llamas are cool');
}