function FilterUITest::testFiltersUI

Same name and namespace in other branches
  1. 9 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 69

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->assertNoRaw('<span>Group 3</span>', 'Group 3 has not been added yet.');
    // Create 2 new groups.
    $this->drupalPostForm(NULL, [], t('Create new filter group'));
    $this->drupalPostForm(NULL, [], t('Create new filter group'));
    // Remove the new group 3.
    $this->drupalPostForm(NULL, [], t('Remove group 3'));
    // Verify that the group 4 is now named as 3.
    $this->assertRaw('<span>Group 3</span>', 'Group 3 still exists.');
    // Remove the group 3 again.
    $this->drupalPostForm(NULL, [], t('Remove group 3'));
    // Group 3 now does not exist.
    $this->assertNoRaw('<span>Group 3</span>', 'Group 3 has not been added yet.');
}

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