function FilterNumericTest::testFilterNumericEmpty

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

File

core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php, line 307

Class

FilterNumericTest
Tests the numeric filter handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testFilterNumericEmpty() {
    $view = Views::getView('test_view');
    $view->setDisplay();
    // Change the filtering
    $view->displayHandlers
        ->get('default')
        ->overrideOption('filters', [
        'age' => [
            'id' => 'age',
            'table' => 'views_test_data',
            'field' => 'age',
            'relationship' => 'none',
            'operator' => 'empty',
        ],
    ]);
    $this->executeView($view);
    $resultset = [];
    $this->assertIdenticalResultset($view, $resultset, $this->columnMap);
    $view->destroy();
    $view->setDisplay();
    // Change the filtering
    $view->displayHandlers
        ->get('default')
        ->overrideOption('filters', [
        'age' => [
            'id' => 'age',
            'table' => 'views_test_data',
            'field' => 'age',
            'relationship' => 'none',
            'operator' => 'not empty',
        ],
    ]);
    $this->executeView($view);
    $resultset = [
        [
            'name' => 'John',
            'age' => 25,
        ],
        [
            'name' => 'George',
            'age' => 27,
        ],
        [
            'name' => 'Ringo',
            'age' => 28,
        ],
        [
            'name' => 'Paul',
            'age' => 26,
        ],
        [
            'name' => 'Meredith',
            'age' => 30,
        ],
    ];
    $this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}

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