function GroupedExposedFilterTest::testGroupedFilterValuesUI

Same name and namespace in other branches
  1. 8.9.x core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/GroupedExposedFilterTest.php \Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler\GroupedExposedFilterTest::testGroupedFilterValuesUI()
  2. 10 core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/GroupedExposedFilterTest.php \Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler\GroupedExposedFilterTest::testGroupedFilterValuesUI()
  3. 11.x core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/GroupedExposedFilterTest.php \Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler\GroupedExposedFilterTest::testGroupedFilterValuesUI()

Tests if the right fields are shown and the right values set.

File

core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/GroupedExposedFilterTest.php, line 76

Class

GroupedExposedFilterTest
Tests the grouped exposed filter admin UI.

Namespace

Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler

Code

public function testGroupedFilterValuesUI() {
    $web_assert = $this->assertSession();
    $this->drupalGet('/admin/structure/views/view/test_exposed_admin_ui');
    $page = $this->getSession()
        ->getPage();
    // Open the dialog for the grouped filter.
    $page->clickLink('Content: Authored on (grouped)');
    $web_assert->assertWaitOnAjaxRequest();
    // Test that the 'min' field is shown and that it contains the right value.
    $between_from = $page->findField('options[group_info][group_items][1][value][min]');
    $this->assertNotEmpty($between_from->isVisible());
    $this->assertEquals('2015-01-01', $between_from->getValue());
    // Test that the 'max' field is shown and that it contains the right value.
    $between_to = $page->findField('options[group_info][group_items][1][value][max]');
    $this->assertNotEmpty($between_to->isVisible());
    $this->assertEquals('2016-01-01', $between_to->getValue());
    $weight = $page->findField('options[group_info][group_items][1][weight]');
    // If there are 3 items, values from -3 to 3 should be available.
    $this->assertNull($weight->find('named', [
        'option',
        -4,
    ]));
    foreach (range(-3, 3) as $value) {
        $this->assertNotEmpty($weight->find('named', [
            'option',
            $value,
        ]));
    }
    $this->assertEmpty($weight->find('named', [
        'option',
        4,
    ]));
    $page->pressButton("Add another item");
    $web_assert->waitForField('options[group_info][group_items][4][title]');
    // A new items was added, weight options should now be -4 to 4.
    $this->assertEmpty($weight->find('named', [
        'option',
        -5,
    ]));
    foreach (range(-4, 4) as $value) {
        $this->assertNotEmpty($weight->find('named', [
            'option',
            $value,
        ]));
    }
    $this->assertEmpty($weight->find('named', [
        'option',
        5,
    ]));
}

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