You are here

protected function RangeViewsFilterTestCase::_testRangeViewsFilter in Range 7

Range views filter test runner.

2 calls to RangeViewsFilterTestCase::_testRangeViewsFilter()
RangeViewsFilterTestCase::testRangeFieldViewsFilter in tests/views/range.views.filter.test
Tests range field views filter.
RangeViewsFilterTestCase::testRangeSearchApiViewsFilter in tests/views/range.views.filter.test
Tests range search API views filter.

File

tests/views/range.views.filter.test, line 44
Contains range views filter handler test class.

Class

RangeViewsFilterTestCase
Tests range views filter handler.

Code

protected function _testRangeViewsFilter($view) {

  // Range contains, exclude endpoints.
  $view
    ->set_display('default');
  $view
    ->init_handlers();
  $view->filter[$this->fieldName]->operator = 'within';
  $view->filter[$this->fieldName]->value = 5;
  $view->filter[$this->fieldName]->options['include_endpoints'] = FALSE;
  $this
    ->executeView($view);
  $expected_result = array(
    array(
      'nid' => $this->nodes[0]->nid,
    ),
    array(
      'nid' => $this->nodes[2]->nid,
    ),
  );
  $this
    ->assertIdenticalResultset($view, $expected_result, $this->map, 'Range views filter (contains, exclude endpoints) produces correct results');
  $view
    ->destroy();

  // Range contains, include endpoints.
  $view
    ->set_display('default');
  $view
    ->init_handlers();
  $view->filter[$this->fieldName]->operator = 'within';
  $view->filter[$this->fieldName]->value = 5;
  $view->filter[$this->fieldName]->options['include_endpoints'] = TRUE;
  $this
    ->executeView($view);
  $expected_result = array(
    array(
      'nid' => $this->nodes[0]->nid,
    ),
    array(
      'nid' => $this->nodes[1]->nid,
    ),
    array(
      'nid' => $this->nodes[2]->nid,
    ),
  );
  $this
    ->assertIdenticalResultset($view, $expected_result, $this->map, 'Range views filter (contains, include endpoints) produces correct results');
  $view
    ->destroy();

  // Range does contains, exclude endpoints.
  $view
    ->set_display('default');
  $view
    ->init_handlers();
  $view->filter[$this->fieldName]->operator = 'not within';
  $view->filter[$this->fieldName]->value = 5;
  $view->filter[$this->fieldName]->options['include_endpoints'] = FALSE;
  $this
    ->executeView($view);
  $expected_result = array(
    array(
      'nid' => $this->nodes[1]->nid,
    ),
    array(
      'nid' => $this->nodes[3]->nid,
    ),
  );
  $this
    ->assertIdenticalResultset($view, $expected_result, $this->map, 'Range views filter (does not contain, exclude endpoints) produces correct results');
  $view
    ->destroy();

  // Range does contains, include endpoints.
  $view
    ->set_display('default');
  $view
    ->init_handlers();
  $view->filter[$this->fieldName]->operator = 'not within';
  $view->filter[$this->fieldName]->value = 5;
  $view->filter[$this->fieldName]->options['include_endpoints'] = TRUE;
  $this
    ->executeView($view);
  $expected_result = array(
    array(
      'nid' => $this->nodes[3]->nid,
    ),
  );
  $this
    ->assertIdenticalResultset($view, $expected_result, $this->map, 'Range views filter (does not contain, include endpoints) produces correct results');
  $view
    ->destroy();
}