You are here

public function FilterNumericTest::testFilterNumericEmpty in Views (for Drupal 7) 8.3

File

lib/Drupal/views/Tests/Handler/FilterNumericTest.php, line 217
Definition of Drupal\views\Tests\Handler\FilterNumericTest.

Class

FilterNumericTest
Tests the numeric filter handler.

Namespace

Drupal\views\Tests\Handler

Code

public function testFilterNumericEmpty() {
  $view = $this
    ->getView();

  // Change the filtering
  $view->displayHandlers['default']
    ->overrideOption('filters', array(
    'age' => array(
      'id' => 'age',
      'table' => 'views_test_data',
      'field' => 'age',
      'relationship' => 'none',
      'operator' => 'empty',
    ),
  ));
  $this
    ->executeView($view);
  $resultset = array();
  $this
    ->assertIdenticalResultset($view, $resultset, $this->column_map);
  $view
    ->destroy();
  $view = $this
    ->getView();

  // Change the filtering
  $view->displayHandlers['default']
    ->overrideOption('filters', array(
    'age' => array(
      'id' => 'age',
      'table' => 'views_test_data',
      'field' => 'age',
      'relationship' => 'none',
      'operator' => 'not empty',
    ),
  ));
  $this
    ->executeView($view);
  $resultset = array(
    array(
      'name' => 'John',
      'age' => 25,
    ),
    array(
      'name' => 'George',
      'age' => 27,
    ),
    array(
      'name' => 'Ringo',
      'age' => 28,
    ),
    array(
      'name' => 'Paul',
      'age' => 26,
    ),
    array(
      'name' => 'Meredith',
      'age' => 30,
    ),
  );
  $this
    ->assertIdenticalResultset($view, $resultset, $this->column_map);
}