You are here

public function WebformListBuilderTest::testFilter in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Functional/WebformListBuilderTest.php \Drupal\Tests\webform\Functional\WebformListBuilderTest::testFilter()

Tests the webform overview filter.

File

tests/src/Functional/WebformListBuilderTest.php, line 22

Class

WebformListBuilderTest
Tests for webform list builder.

Namespace

Drupal\Tests\webform\Functional

Code

public function testFilter() {
  $this
    ->drupalLogin($this->rootUser);

  // Check filter default category and state.
  $this
    ->drupalGet('/admin/structure/webform');
  $this
    ->assertOptionSelected('edit-category', '');
  $this
    ->assertOptionSelected('edit-state', '');

  // Set filter category and state.
  \Drupal::configFactory()
    ->getEditable('webform.settings')
    ->set('form.filter_category', 'Test: Submissions')
    ->set('form.filter_state', 'open')
    ->save();

  // Check filter customized category and state.
  $this
    ->drupalGet('/admin/structure/webform');
  $this
    ->assertOptionSelected('edit-category', 'Test: Submissions');
  $this
    ->assertOptionSelected('edit-state', 'open');

  // Check customized filter can still be cleared.
  $this
    ->drupalGet('/admin/structure/webform', [
    'query' => [
      'category' => '',
      'state' => '',
    ],
  ]);
  $this
    ->assertOptionSelected('edit-category', '');
  $this
    ->assertOptionSelected('edit-state', '');
}