You are here

public function FilterNumericTest::testAllowEmpty in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/views/src/Tests/Handler/FilterNumericTest.php \Drupal\views\Tests\Handler\FilterNumericTest::testAllowEmpty()

File

core/modules/views/src/Tests/Handler/FilterNumericTest.php, line 350
Contains \Drupal\views\Tests\Handler\FilterNumericTest.

Class

FilterNumericTest
Tests the numeric filter handler.

Namespace

Drupal\views\Tests\Handler

Code

public function testAllowEmpty() {
  $view = Views::getView('test_view');
  $view
    ->setDisplay();
  $view->displayHandlers
    ->get('default')
    ->overrideOption('filters', array(
    'id' => array(
      'id' => 'id',
      'table' => 'views_test_data',
      'field' => 'id',
      'relationship' => 'none',
    ),
    'age' => array(
      'id' => 'age',
      'table' => 'views_test_data',
      'field' => 'age',
      'relationship' => 'none',
    ),
  ));
  $view
    ->initHandlers();
  $id_operators = $view->filter['id']
    ->operators();
  $age_operators = $view->filter['age']
    ->operators();
  $this
    ->assertFalse(isset($id_operators['empty']));
  $this
    ->assertFalse(isset($id_operators['not empty']));
  $this
    ->assertTrue(isset($age_operators['empty']));
  $this
    ->assertTrue(isset($age_operators['not empty']));
}