function FilterUITest::testFiltersUI

Same name and namespace in other branches
  1. 8.9.x core/modules/views_ui/tests/src/Functional/FilterUITest.php \Drupal\Tests\views_ui\Functional\FilterUITest::testFiltersUI()
  2. 10 core/modules/views_ui/tests/src/Functional/FilterUITest.php \Drupal\Tests\views_ui\Functional\FilterUITest::testFiltersUI()
  3. 11.x core/modules/views_ui/tests/src/Functional/FilterUITest.php \Drupal\Tests\views_ui\Functional\FilterUITest::testFiltersUI()

Tests the filters from the UI.

File

core/modules/views_ui/tests/src/Functional/FilterUITest.php, line 70

Class

FilterUITest
Tests for the filters from the UI.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testFiltersUI() {
    $admin_user = $this->drupalCreateUser([
        'administer views',
        'administer site configuration',
    ]);
    $this->drupalLogin($admin_user);
    $this->drupalGet('admin/structure/views/view/test_filter_groups');
    $this->assertSession()
        ->linkExists('Content: ID (= 1)', 0, 'Content: ID (= 1) link appears correctly.');
    // Tests that we can create a new filter group from UI.
    $this->drupalGet('admin/structure/views/nojs/rearrange-filter/test_filter_groups/page');
    $this->assertSession()
        ->elementNotExists('xpath', '//span[text()="Group 3"]');
    // Create 2 new groups.
    $this->submitForm([], 'Create new filter group');
    $this->submitForm([], 'Create new filter group');
    // Remove the new group 3.
    $this->submitForm([], 'Remove group 3');
    // Verify that the group 4 is now named as 3.
    $this->assertSession()
        ->responseContains('<span>Group 3</span>');
    // Remove the group 3 again.
    $this->submitForm([], 'Remove group 3');
    // Group 3 now does not exist.
    $this->assertSession()
        ->elementNotExists('xpath', '//span[text()="Group 3"]');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.