function FilterBooleanOperatorStringTest::testFilterBooleanOperatorString

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

Tests the BooleanOperatorString filter.

File

core/modules/views/tests/src/Kernel/Handler/FilterBooleanOperatorStringTest.php, line 88

Class

FilterBooleanOperatorStringTest
Tests core's BooleanOperatorString views filter handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testFilterBooleanOperatorString() {
    $view = Views::getView('test_view');
    $view->setDisplay();
    // Add a the status boolean filter.
    $view->displayHandlers
        ->get('default')
        ->overrideOption('filters', [
        'status' => [
            'id' => 'status',
            'field' => 'status',
            'table' => 'views_test_data',
            'value' => 0,
        ],
    ]);
    $this->executeView($view);
    $expected_result = [
        [
            'id' => 2,
        ],
        [
            'id' => 4,
        ],
    ];
    $this->assertCount(2, $view->result);
    $this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
    $view->destroy();
    $view->setDisplay();
    // Add the status boolean filter.
    $view->displayHandlers
        ->get('default')
        ->overrideOption('filters', [
        'status' => [
            'id' => 'status',
            'field' => 'status',
            'table' => 'views_test_data',
            'value' => 1,
        ],
    ]);
    $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.