function FilterBooleanOperatorTest::testFilterGroupedExposed

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorTest.php \Drupal\Tests\views\Kernel\Handler\FilterBooleanOperatorTest::testFilterGroupedExposed()
  2. 8.9.x core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorTest.php \Drupal\Tests\views\Kernel\Handler\FilterBooleanOperatorTest::testFilterGroupedExposed()
  3. 10 core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorTest.php \Drupal\Tests\views\Kernel\Handler\FilterBooleanOperatorTest::testFilterGroupedExposed()

Tests the boolean filter with grouped exposed form enabled.

File

core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorTest.php, line 118

Class

FilterBooleanOperatorTest
Tests the core <a href="/api/drupal/core%21modules%21views%21src%21Plugin%21views%21filter%21BooleanOperator.php/class/BooleanOperator/11.x" title="Simple filter to handle matching of boolean values." class="local">Drupal\views\Plugin\views\filter\BooleanOperator</a> handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testFilterGroupedExposed() : void {
    $filters = $this->getGroupedExposedFilters();
    $view = Views::getView('test_view');
    $view->setExposedInput([
        'status' => 1,
    ]);
    $view->setDisplay();
    $view->displayHandlers
        ->get('default')
        ->overrideOption('filters', $filters);
    $this->executeView($view);
    $expected_result = [
        [
            'id' => 1,
        ],
        [
            'id' => 3,
        ],
        [
            'id' => 5,
        ],
    ];
    $this->assertCount(3, $view->result);
    $this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
    $view->destroy();
    $view->setExposedInput([
        'status' => 2,
    ]);
    $view->setDisplay();
    $view->displayHandlers
        ->get('default')
        ->overrideOption('filters', $filters);
    $this->executeView($view);
    $expected_result = [
        [
            'id' => 2,
        ],
        [
            'id' => 4,
        ],
    ];
    $this->assertCount(2, $view->result);
    $this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
    $view->destroy();
    // Expecting the same results as for ['status' => 1].
    $view->setExposedInput([
        'status' => 3,
    ]);
    $view->setDisplay();
    $view->displayHandlers
        ->get('default')
        ->overrideOption('filters', $filters);
    $this->executeView($view);
    $expected_result = [
        [
            'id' => 1,
        ],
        [
            'id' => 3,
        ],
        [
            'id' => 5,
        ],
    ];
    $this->assertCount(3, $view->result);
    $this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
}

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