summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_numeric.test
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_numeric.test')
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_numeric.test196
1 files changed, 195 insertions, 1 deletions
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_numeric.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_numeric.test
index 0112118..2ab1aea 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_numeric.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_numeric.test
@@ -1,11 +1,19 @@
<?php
+/**
+ * @file
+ * Definition of ViewsHandlerFilterNumericTest.
+ */
+
+/**
+ * Tests the numeric filter handler.
+ */
class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
var $column_map = array();
public static function getInfo() {
return array(
- 'name' => 'Handlers: filter_numeric',
+ 'name' => 'Filter: Numeric',
'description' => 'Tests the numeric filter handler',
'group' => 'Views Handlers',
);
@@ -52,6 +60,25 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+ public function testFilterNumericExposedGroupedSimple() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Age, Operator: =, Value: 28
+ $filters['age']['group_info']['default_group'] = 1;
+ $view->set_display('page_1');
+ $view->display['page_1']->handler->override_option('filters', $filters);
+
+ $this->executeView($view);
+ $resultset = array(
+ array(
+ 'name' => 'Ringo',
+ 'age' => 28,
+ ),
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
public function testFilterNumericBetween() {
$view = $this->getBasicView();
@@ -124,6 +151,63 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+ public function testFilterNumericExposedGroupedBetween() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Age, Operator: between, Value: 26 and 29
+ $filters['age']['group_info']['default_group'] = 2;
+ $view->set_display('page_1');
+ $view->display['page_1']->handler->override_option('filters', $filters);
+
+
+ $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);
+ }
+
+ public function testFilterNumericExposedGroupedNotBetween() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Age, Operator: between, Value: 26 and 29
+ $filters['age']['group_info']['default_group'] = 3;
+ $view->set_display('page_1');
+ $view->display['page_1']->handler->override_option('filters', $filters);
+
+
+ $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);
+ }
+
+
public function testFilterNumericEmpty() {
$view = $this->getBasicView();
@@ -183,6 +267,60 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+
+ public function testFilterNumericExposedGroupedEmpty() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Age, Operator: empty, Value:
+ $filters['age']['group_info']['default_group'] = 4;
+ $view->set_display('page_1');
+ $view->display['page_1']->handler->override_option('filters', $filters);
+
+
+ $this->executeView($view);
+ $resultset = array(
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
+ public function testFilterNumericExposedGroupedNotEmpty() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Age, Operator: empty, Value:
+ $filters['age']['group_info']['default_group'] = 5;
+ $view->set_display('page_1');
+ $view->display['page_1']->handler->override_option('filters', $filters);
+
+
+ $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);
+ }
+
+
public function testAllowEmpty() {
$view = $this->getBasicView();
@@ -212,4 +350,60 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
$this->assertTrue(isset($age_operators['empty']));
$this->assertTrue(isset($age_operators['not empty']));
}
+
+ protected function getGroupedExposedFilters() {
+ $filters = array(
+ 'age' => array(
+ 'id' => 'age',
+ 'table' => 'views_test',
+ 'field' => 'age',
+ 'relationship' => 'none',
+ 'exposed' => TRUE,
+ 'expose' => array(
+ 'operator' => 'age_op',
+ 'label' => 'age',
+ 'identifier' => 'age',
+ ),
+ 'is_grouped' => TRUE,
+ 'group_info' => array(
+ 'label' => 'age',
+ 'identifier' => 'age',
+ 'default_group' => 'All',
+ 'group_items' => array(
+ 1 => array(
+ 'title' => 'Age is 28',
+ 'operator' => '=',
+ 'value' => array('value' => 28),
+ ),
+ 2 => array(
+ 'title' => 'Age is between 26 and 29',
+ 'operator' => 'between',
+ 'value' => array(
+ 'min' => 26,
+ 'max' => 29,
+ ),
+ ),
+ 3 => array(
+ 'title' => 'Age is not between 26 and 29',
+ 'operator' => 'not between',
+ 'value' => array(
+ 'min' => 26,
+ 'max' => 29,
+ ),
+ ),
+ 4 => array(
+ 'title' => 'Age is empty',
+ 'operator' => 'empty',
+ ),
+ 5 => array(
+ 'title' => 'Age is not empty',
+ 'operator' => 'not empty',
+ ),
+ ),
+ ),
+ ),
+ );
+ return $filters;
+ }
+
}