You are here

protected function ViewsHandlerFilterNumericTest::applyFilterNumericExposedOperator in Views (for Drupal 7) 7.3

Tests exposed numeric filter with an individual exposed operator.

Parameters

string $operator: Operator to test.

array $value: Filter value to use in exposed input. Keys might be 'value', 'min' or 'max'. If one of those keys doesn't exist, an empty string is used as the key's value.

array $resultset: The expected result set.

1 call to ViewsHandlerFilterNumericTest::applyFilterNumericExposedOperator()
ViewsHandlerFilterNumericTest::testFilterNumericExposedOperator in tests/handlers/views_handler_filter_numeric.test
Tests exposed numeric filter with exposed operator.

File

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

Class

ViewsHandlerFilterNumericTest
Tests the numeric filter handler.

Code

protected function applyFilterNumericExposedOperator($operator, array $value, array $resultset) {
  $exposed_input = array(
    'age' => $value += array(
      'value' => '',
      'min' => '',
      'max' => '',
    ),
    'age_op' => $operator,
  );
  $filters = array(
    'age' => array(
      'id' => 'age',
      'table' => 'views_test',
      'field' => 'age',
      'relationship' => 'none',
      'exposed' => TRUE,
      'expose' => array(
        'operator' => 'age_op',
        'label' => 'age',
        'identifier' => 'age',
        'use_operator' => TRUE,
      ),
    ),
  );
  $view = $this
    ->getBasicPageView();
  $view
    ->set_display('page_1');
  $view->display['page_1']->handler
    ->override_option('filters', $filters);
  $view
    ->set_exposed_input($exposed_input);
  $this
    ->executeView($view);
  $this
    ->assertIdenticalResultset($view, $resultset, $this->column_map, 'Identical result set for ' . $operator . ' with untouched values.');
  $view
    ->destroy();

  // Min, max and value fields are shown/hidden only via JS, so they might
  // still be set from a previous operation. Assert that this doesn't change
  // the expected result set.
  $exposed_input['age'] += array(
    'value' => '25',
    'min' => '28',
    'max' => '30',
  );
  $view = $this
    ->getBasicPageView();
  $view
    ->set_display('page_1');
  $view->display['page_1']->handler
    ->override_option('filters', $filters);
  $view
    ->set_exposed_input($exposed_input);
  $this
    ->executeView($view);
  $this
    ->assertIdenticalResultset($view, $resultset, $this->column_map, 'Identical result set for ' . $operator . ' with leftover values from previous operation.');
}