You are here

public function ViewsHandlerFilterNumericTest::testFilterNumericBetween in Views (for Drupal 7) 7.3

File

tests/handlers/views_handler_filter_numeric.test, line 110
Definition of ViewsHandlerFilterNumericTest.

Class

ViewsHandlerFilterNumericTest
Tests the numeric filter handler.

Code

public function testFilterNumericBetween() {
  $view = $this
    ->getBasicView();

  // Change the filtering.
  $view->display['default']->handler
    ->override_option('filters', array(
    'age' => array(
      'id' => 'age',
      'table' => 'views_test',
      'field' => 'age',
      'relationship' => 'none',
      'operator' => 'between',
      'value' => array(
        'min' => 26,
        'max' => 29,
      ),
    ),
  ));
  $this
    ->executeView($view);
  $resultset = array(
    array(
      'name' => 'George',
      'age' => 27,
    ),
    array(
      'name' => 'Ringo',
      'age' => 28,
    ),
    array(
      'name' => 'Paul',
      'age' => 26,
    ),
  );
  $this
    ->assertIdenticalResultset($view, $resultset, $this->column_map);

  // Test not between.
  $view
    ->delete();
  $view = $this
    ->getBasicView();

  // Change the filtering.
  $view->display['default']->handler
    ->override_option('filters', array(
    'age' => array(
      'id' => 'age',
      'table' => 'views_test',
      'field' => 'age',
      'relationship' => 'none',
      'operator' => 'not between',
      'value' => array(
        'min' => 26,
        'max' => 29,
      ),
    ),
  ));
  $this
    ->executeView($view);
  $resultset = array(
    array(
      'name' => 'John',
      'age' => 25,
    ),
    array(
      'name' => 'Paul',
      'age' => 26,
    ),
    array(
      'name' => 'Meredith',
      'age' => 30,
    ),
  );
  $this
    ->assertIdenticalResultset($view, $resultset, $this->column_map);
}