summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_in_operator.test
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_in_operator.test')
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_in_operator.test107
1 files changed, 107 insertions, 0 deletions
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_in_operator.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_in_operator.test
index 04ac5de..3a20f8c 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_in_operator.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_in_operator.test
@@ -1,5 +1,13 @@
<?php
+/**
+ * @file
+ * Definition of ViewsHandlerFilterInOperator.
+ */
+
+/**
+ * Tests the core views_handler_filter_in_operator handler.
+ */
class ViewsHandlerFilterInOperator extends ViewsSqlTest {
public static function getInfo() {
return array(
@@ -86,4 +94,103 @@ class ViewsHandlerFilterInOperator extends ViewsSqlTest {
'views_test_age' => 'age',
));
}
+
+ public function testFilterInOperatorGroupedExposedSimple() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Age, Operator: in, Value: 26, 30
+ $filters['age']['group_info']['default_group'] = 1;
+ $view->set_display('page_1');
+ $view->display['page_1']->handler->override_option('filters', $filters);
+
+ $this->executeView($view);
+
+ $expected_result = array(
+ array(
+ 'name' => 'Paul',
+ 'age' => 26,
+ ),
+ array(
+ 'name' => 'Meredith',
+ 'age' => 30,
+ ),
+ );
+
+ $this->assertEqual(2, count($view->result));
+ $this->assertIdenticalResultset($view, $expected_result, array(
+ 'views_test_name' => 'name',
+ 'views_test_age' => 'age',
+ ));
+ }
+
+ public function testFilterNotInOperatorGroupedExposedSimple() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Age, Operator: in, Value: 26, 30
+ $filters['age']['group_info']['default_group'] = 2;
+ $view->set_display('page_1');
+ $view->display['page_1']->handler->override_option('filters', $filters);
+
+ $this->executeView($view);
+
+ $expected_result = array(
+ array(
+ 'name' => 'John',
+ 'age' => 25,
+ ),
+ array(
+ 'name' => 'George',
+ 'age' => 27,
+ ),
+ array(
+ 'name' => 'Ringo',
+ 'age' => 28,
+ ),
+ );
+
+ $this->assertEqual(3, count($view->result));
+ $this->assertIdenticalResultset($view, $expected_result, array(
+ 'views_test_name' => 'name',
+ 'views_test_age' => 'age',
+ ));
+ }
+
+ 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 one of 26, 30',
+ 'operator' => 'in',
+ 'value' => array(26, 30),
+ ),
+ 2 => array(
+ 'title' => 'Age is not one of 26, 30',
+ 'operator' => 'not in',
+ 'value' => array(26, 30),
+ ),
+ ),
+ ),
+ ),
+ );
+ return $filters;
+ }
+
}