summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers')
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_area_text.test5
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_argument_null.test8
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_argument_string.test96
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field.test227
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_boolean.test8
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_counter.test10
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_custom.test8
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_date.test55
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_file_size.test7
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_math.test8
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_url.test8
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_xss.test7
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_combine.test105
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_date.test11
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_equality.test91
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_in_operator.test107
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_numeric.test196
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_string.test403
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort.test11
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort_date.test9
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort_random.test11
21 files changed, 1352 insertions, 39 deletions
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_area_text.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_area_text.test
index d9724a4..9f30e0c 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_area_text.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_area_text.test
@@ -1,6 +1,11 @@
<?php
/**
+ * @file
+ * Definition of ViewsHandlerAreaTextTest.
+ */
+
+/**
* Tests the text area handler.
*
* @see views_handler_area_text
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_argument_null.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_argument_null.test
index da01136..e8650a3 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_argument_null.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_argument_null.test
@@ -1,5 +1,13 @@
<?php
+/**
+ * @file
+ * Definition of ViewsHandlerArgumentNullTest.
+ */
+
+/**
+ * Tests the core views_handler_argument_null handler.
+ */
class ViewsHandlerArgumentNullTest extends ViewsSqlTest {
public static function getInfo() {
return array(
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_argument_string.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_argument_string.test
new file mode 100644
index 0000000..d078abf
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_argument_string.test
@@ -0,0 +1,96 @@
+<?php
+/**
+ * @file
+ * Definition of ViewsHandlerArgumentNullTest.
+ */
+
+/**
+ * Tests the core views_handler_argument_string handler.
+ */
+class ViewsHandlerArgumentStringTest extends ViewsSqlTest {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Argument: String',
+ 'description' => 'Test the core views_handler_argument_string handler.',
+ 'group' => 'Views Handlers',
+ );
+ }
+
+ /**
+ * Tests the glossary feature.
+ */
+ function testGlossary() {
+ // Setup some nodes, one with a, two with b and three with c.
+ $counter = 1;
+ foreach (array('a', 'b', 'c') as $char) {
+ for ($i = 0; $i < $counter; $i++) {
+ $edit = array(
+ 'title' => $char . $this->randomName(),
+ );
+ $this->drupalCreateNode($edit);
+ }
+ }
+
+ $view = $this->viewGlossary();
+ $view->init_display();
+ $this->executeView($view);
+
+ $count_field = 'nid';
+ foreach ($view->result as &$row) {
+ if (strpos($row->node_title, 'a') === 0) {
+ $this->assertEqual(1, $row->{$count_field});
+ }
+ if (strpos($row->node_title, 'b') === 0) {
+ $this->assertEqual(2, $row->{$count_field});
+ }
+ if (strpos($row->node_title, 'c') === 0) {
+ $this->assertEqual(3, $row->{$count_field});
+ }
+ }
+ }
+
+ /**
+ * Provide a test view for testGlossary.
+ *
+ * @see testGlossary
+ * @return view
+ */
+ function viewGlossary() {
+ $view = new view();
+ $view->name = 'test_glossary';
+ $view->description = '';
+ $view->tag = 'default';
+ $view->base_table = 'node';
+ $view->human_name = 'test_glossary';
+ $view->core = 7;
+ $view->api_version = '3.0';
+ $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+ /* Display: Master */
+ $handler = $view->new_display('default', 'Master', 'default');
+ $handler->display->display_options['access']['type'] = 'perm';
+ $handler->display->display_options['cache']['type'] = 'none';
+ $handler->display->display_options['query']['type'] = 'views_query';
+ $handler->display->display_options['exposed_form']['type'] = 'basic';
+ $handler->display->display_options['pager']['type'] = 'full';
+ $handler->display->display_options['style_plugin'] = 'default';
+ $handler->display->display_options['row_plugin'] = 'fields';
+ /* Field: Content: Title */
+ $handler->display->display_options['fields']['title']['id'] = 'title';
+ $handler->display->display_options['fields']['title']['table'] = 'node';
+ $handler->display->display_options['fields']['title']['field'] = 'title';
+ $handler->display->display_options['fields']['title']['label'] = '';
+ /* Contextual filter: Content: Title */
+ $handler->display->display_options['arguments']['title']['id'] = 'title';
+ $handler->display->display_options['arguments']['title']['table'] = 'node';
+ $handler->display->display_options['arguments']['title']['field'] = 'title';
+ $handler->display->display_options['arguments']['title']['default_argument_type'] = 'fixed';
+ $handler->display->display_options['arguments']['title']['summary']['number_of_records'] = '0';
+ $handler->display->display_options['arguments']['title']['summary']['format'] = 'default_summary';
+ $handler->display->display_options['arguments']['title']['summary_options']['items_per_page'] = '25';
+ $handler->display->display_options['arguments']['title']['glossary'] = TRUE;
+ $handler->display->display_options['arguments']['title']['limit'] = '1';
+
+ return $view;
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field.test
index 726857e..9e6dfca 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field.test
@@ -2,7 +2,7 @@
/**
* @file
- * Contains tests for views_handler_field.
+ * Definition of ViewsHandlerFieldTest.
*/
/**
@@ -39,39 +39,216 @@ class ViewsHandlerFieldTest extends ViewsSqlTest {
function _testHideIfEmpty() {
$view = $this->getBasicView();
$view->init_display();
- $view->pre_execute();
- $view->execute();
+ $this->executeView($view);
$column_map_reversed = array_flip($this->column_map);
$view->row_index = 0;
+ $random_name = $this->randomName();
+ $random_value = $this->randomName();
+
+ // Test when results are not rewritten and empty values are not hidden.
+ $view->field['name']->options['hide_alter_empty'] = FALSE;
+ $view->field['name']->options['hide_empty'] = FALSE;
+ $view->field['name']->options['empty_zero'] = FALSE;
+
+ // Test a valid string.
+ $view->result[0]->{$column_map_reversed['name']} = $random_name;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, $random_name, 'By default, a string should not be treated as empty.');
+
+ // Test an empty string.
+ $view->result[0]->{$column_map_reversed['name']} = "";
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, "", 'By default, "" should not be treated as empty.');
+
+ // Test zero as an integer.
+ $view->result[0]->{$column_map_reversed['name']} = 0;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, '0', 'By default, 0 should not be treated as empty.');
+
+ // Test zero as a string.
+ $view->result[0]->{$column_map_reversed['name']} = "0";
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, "0", 'By default, "0" should not be treated as empty.');
+ // Test when results are not rewritten and non-zero empty values are hidden.
+ $view->field['name']->options['hide_alter_empty'] = TRUE;
$view->field['name']->options['hide_empty'] = TRUE;
+ $view->field['name']->options['empty_zero'] = FALSE;
+
+ // Test a valid string.
+ $view->result[0]->{$column_map_reversed['name']} = $random_name;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, $random_name, 'If hide_empty is checked, a string should not be treated as empty.');
+
+ // Test an empty string.
$view->result[0]->{$column_map_reversed['name']} = "";
$render = $view->field['name']->advanced_render($view->result[0]);
$this->assertIdentical($render, "", 'If hide_empty is checked, "" should be treated as empty.');
- $view->field['name']->options['empty_zero'] = FALSE;
+ // Test zero as an integer.
+ $view->result[0]->{$column_map_reversed['name']} = 0;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, '0', 'If hide_empty is checked, but not empty_zero, 0 should not be treated as empty.');
+
+ // Test zero as a string.
$view->result[0]->{$column_map_reversed['name']} = "0";
$render = $view->field['name']->advanced_render($view->result[0]);
- $this->assertIdentical($render, "0", 'If hide_empty is checked, but not empty_zero, "0" should be treated as not empty.');
+ $this->assertIdentical($render, "0", 'If hide_empty is checked, but not empty_zero, "0" should not be treated as empty.');
+ // Test when results are not rewritten and all empty values are hidden.
+ $view->field['name']->options['hide_alter_empty'] = TRUE;
+ $view->field['name']->options['hide_empty'] = TRUE;
$view->field['name']->options['empty_zero'] = TRUE;
+
+ // Test zero as an integer.
+ $view->result[0]->{$column_map_reversed['name']} = 0;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, "", 'If hide_empty and empty_zero are checked, 0 should be treated as empty.');
+
+ // Test zero as a string.
+ $view->result[0]->{$column_map_reversed['name']} = "0";
$render = $view->field['name']->advanced_render($view->result[0]);
$this->assertIdentical($render, "", 'If hide_empty and empty_zero are checked, "0" should be treated as empty.');
+ // Test when results are rewritten to a valid string and non-zero empty
+ // results are hidden.
$view->field['name']->options['hide_alter_empty'] = FALSE;
+ $view->field['name']->options['hide_empty'] = TRUE;
+ $view->field['name']->options['empty_zero'] = FALSE;
$view->field['name']->options['alter']['alter_text'] = TRUE;
- $view->result[0]->{$column_map_reversed['name']} = "";
- $random_name = $this->randomName();
$view->field['name']->options['alter']['text'] = $random_name;
+
+ // Test a valid string.
+ $view->result[0]->{$column_map_reversed['name']} = $random_value;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, $random_name, 'If the rewritten string is not empty, it should not be treated as empty.');
+
+ // Test an empty string.
+ $view->result[0]->{$column_map_reversed['name']} = "";
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, $random_name, 'If the rewritten string is not empty, "" should not be treated as empty.');
+
+ // Test zero as an integer.
+ $view->result[0]->{$column_map_reversed['name']} = 0;
$render = $view->field['name']->advanced_render($view->result[0]);
- $this->assertIdentical($render, $random_name, 'If hide_empty but not hide_alter_empty is checked, some rewrite should appear even if the value is empty.');
+ $this->assertIdentical($render, $random_name, 'If the rewritten string is not empty, 0 should not be treated as empty.');
+ // Test zero as a string.
+ $view->result[0]->{$column_map_reversed['name']} = "0";
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, $random_name, 'If the rewritten string is not empty, "0" should not be treated as empty.');
+
+ // Test when results are rewritten to an empty string and non-zero empty results are hidden.
$view->field['name']->options['hide_alter_empty'] = TRUE;
- $random_name = $this->randomName();
- $view->field['name']->options['alter']['text'] = $random_name;
+ $view->field['name']->options['hide_empty'] = TRUE;
+ $view->field['name']->options['empty_zero'] = FALSE;
+ $view->field['name']->options['alter']['alter_text'] = TRUE;
+ $view->field['name']->options['alter']['text'] = "";
+
+ // Test a valid string.
+ $view->result[0]->{$column_map_reversed['name']} = $random_name;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, $random_name, 'If the rewritten string is empty, it should not be treated as empty.');
+
+ // Test an empty string.
+ $view->result[0]->{$column_map_reversed['name']} = "";
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, "", 'If the rewritten string is empty, "" should be treated as empty.');
+
+ // Test zero as an integer.
+ $view->result[0]->{$column_map_reversed['name']} = 0;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, '0', 'If the rewritten string is empty, 0 should not be treated as empty.');
+
+ // Test zero as a string.
+ $view->result[0]->{$column_map_reversed['name']} = "0";
$render = $view->field['name']->advanced_render($view->result[0]);
- $this->assertIdentical($render, "", 'If hide_empty and hide_alter_empty are checked, rewrite should be empty all the time.');
+ $this->assertIdentical($render, "0", 'If the rewritten string is empty, "0" should not be treated as empty.');
+
+ // Test when results are rewritten to zero as a string and non-zero empty
+ // results are hidden.
+ $view->field['name']->options['hide_alter_empty'] = FALSE;
+ $view->field['name']->options['hide_empty'] = TRUE;
+ $view->field['name']->options['empty_zero'] = FALSE;
+ $view->field['name']->options['alter']['alter_text'] = TRUE;
+ $view->field['name']->options['alter']['text'] = "0";
+
+ // Test a valid string.
+ $view->result[0]->{$column_map_reversed['name']} = $random_name;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, "0", 'If the rewritten string is zero and empty_zero is not checked, the string rewritten as 0 should not be treated as empty.');
+
+ // Test an empty string.
+ $view->result[0]->{$column_map_reversed['name']} = "";
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, "0", 'If the rewritten string is zero and empty_zero is not checked, "" rewritten as 0 should not be treated as empty.');
+
+ // Test zero as an integer.
+ $view->result[0]->{$column_map_reversed['name']} = 0;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, "0", 'If the rewritten string is zero and empty_zero is not checked, 0 should not be treated as empty.');
+
+ // Test zero as a string.
+ $view->result[0]->{$column_map_reversed['name']} = "0";
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, "0", 'If the rewritten string is zero and empty_zero is not checked, "0" should not be treated as empty.');
+
+ // Test when results are rewritten to a valid string and non-zero empty
+ // results are hidden.
+ $view->field['name']->options['hide_alter_empty'] = TRUE;
+ $view->field['name']->options['hide_empty'] = TRUE;
+ $view->field['name']->options['empty_zero'] = FALSE;
+ $view->field['name']->options['alter']['alter_text'] = TRUE;
+ $view->field['name']->options['alter']['text'] = $random_value;
+
+ // Test a valid string.
+ $view->result[0]->{$column_map_reversed['name']} = $random_name;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, $random_value, 'If the original and rewritten strings are valid, it should not be treated as empty.');
+
+ // Test an empty string.
+ $view->result[0]->{$column_map_reversed['name']} = "";
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, "", 'If either the original or rewritten string is invalid, "" should be treated as empty.');
+
+ // Test zero as an integer.
+ $view->result[0]->{$column_map_reversed['name']} = 0;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, $random_value, 'If the original and rewritten strings are valid, 0 should not be treated as empty.');
+
+ // Test zero as a string.
+ $view->result[0]->{$column_map_reversed['name']} = "0";
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, $random_value, 'If the original and rewritten strings are valid, "0" should not be treated as empty.');
+
+ // Test when results are rewritten to zero as a string and all empty
+ // original values and results are hidden.
+ $view->field['name']->options['hide_alter_empty'] = TRUE;
+ $view->field['name']->options['hide_empty'] = TRUE;
+ $view->field['name']->options['empty_zero'] = TRUE;
+ $view->field['name']->options['alter']['alter_text'] = TRUE;
+ $view->field['name']->options['alter']['text'] = "0";
+
+ // Test a valid string.
+ $view->result[0]->{$column_map_reversed['name']} = $random_name;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, "", 'If the rewritten string is zero, it should be treated as empty.');
+
+ // Test an empty string.
+ $view->result[0]->{$column_map_reversed['name']} = "";
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, "", 'If the rewritten string is zero, "" should be treated as empty.');
+
+ // Test zero as an integer.
+ $view->result[0]->{$column_map_reversed['name']} = 0;
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, "", 'If the rewritten string is zero, 0 should not be treated as empty.');
+
+ // Test zero as a string.
+ $view->result[0]->{$column_map_reversed['name']} = "0";
+ $render = $view->field['name']->advanced_render($view->result[0]);
+ $this->assertIdentical($render, "", 'If the rewritten string is zero, "0" should not be treated as empty.');
}
/**
@@ -80,8 +257,7 @@ class ViewsHandlerFieldTest extends ViewsSqlTest {
function _testEmptyText() {
$view = $this->getBasicView();
$view->init_display();
- $view->pre_execute();
- $view->execute();
+ $this->executeView($view);
$column_map_reversed = array_flip($this->column_map);
$view->row_index = 0;
@@ -112,4 +288,27 @@ class ViewsHandlerFieldTest extends ViewsSqlTest {
$this->assertIdentical($render, $empty_text, 'If a field is empty, some rewrite text exists, and hide_alter_empty is checked, use the empty text.');
}
-} \ No newline at end of file
+ /**
+ * Tests views_handler_field::is_value_empty().
+ */
+ function testIsValueEmpty() {
+ $view = $this->getBasicView();
+ $view->init_display();
+ $view->init_handlers();
+ $field = $view->field['name'];
+
+ $this->assertFalse($field->is_value_empty("not empty", TRUE), 'A normal string is not empty.');
+ $this->assertTrue($field->is_value_empty("not empty", TRUE, FALSE), 'A normal string which skips empty() can be seen as empty.');
+
+ $this->assertTrue($field->is_value_empty("", TRUE), '"" is considered as empty.');
+
+ $this->assertTrue($field->is_value_empty('0', TRUE), '"0" is considered as empty if empty_zero is TRUE.');
+ $this->assertTrue($field->is_value_empty(0, TRUE), '0 is considered as empty if empty_zero is TRUE.');
+ $this->assertFalse($field->is_value_empty('0', FALSE), '"0" is considered not as empty if empty_zero is FALSE.');
+ $this->assertFalse($field->is_value_empty(0, FALSE), '0 is considered not as empty if empty_zero is FALSE.');
+
+ $this->assertTrue($field->is_value_empty(NULL, TRUE, TRUE), 'Null should be always seen as empty, regardless of no_skip_empty.');
+ $this->assertTrue($field->is_value_empty(NULL, TRUE, FALSE), 'Null should be always seen as empty, regardless of no_skip_empty.');
+ }
+
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_boolean.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_boolean.test
index 54b4287..92ec7a5 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_boolean.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_boolean.test
@@ -1,5 +1,13 @@
<?php
+/**
+ * @file
+ * Definition of ViewsHandlerFieldBooleanTest.
+ */
+
+/**
+ * Tests the core views_handler_field_boolean handler.
+ */
class ViewsHandlerFieldBooleanTest extends ViewsSqlTest {
public static function getInfo() {
return array(
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_counter.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_counter.test
index c628a79..2ddcb6f 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_counter.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_counter.test
@@ -1,10 +1,18 @@
<?php
+/**
+ * @file
+ * Definition of ViewsHandlerFilterCounterTest.
+ */
+
+/**
+ * Tests the views_handler_field_counter handler.
+ */
class ViewsHandlerFilterCounterTest extends ViewsSqlTest {
public static function getInfo() {
return array(
'name' => 'Field: Counter',
- 'description' => 'Tests the views_handler_field_counter handler',
+ 'description' => 'Tests the views_handler_field_counter handler.',
'group' => 'Views Handlers',
);
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_custom.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_custom.test
index 787cdbd..b45fd17 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_custom.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_custom.test
@@ -1,5 +1,13 @@
<?php
+/**
+ * @file
+ * Definition of ViewsHandlerFieldCustomTest.
+ */
+
+/**
+ * Tests the core views_handler_field_custom handler.
+ */
class ViewsHandlerFieldCustomTest extends ViewsSqlTest {
public static function getInfo() {
return array(
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_date.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_date.test
index 0b9bde5..028b687 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_date.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_date.test
@@ -1,5 +1,13 @@
<?php
+/**
+ * @file
+ * Definition of ViewsHandlerFieldDateTest.
+ */
+
+/**
+ * Tests the core views_handler_field_date handler.
+ */
class ViewsHandlerFieldDateTest extends ViewsSqlTest {
public static function getInfo() {
return array(
@@ -30,25 +38,50 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest {
));
$time = gmmktime(0, 0, 0, 1, 1, 2000);
- $maps = array(
- 'small' => format_date($time, 'small'),
- 'medium' => format_date($time, 'medium'),
- 'large' => format_date($time, 'large'),
- 'custom' => format_date($time, 'custom', 'c'),
+ $this->executeView($view);
+
+ $timezones = array(
+ NULL,
+ 'UTC',
+ 'America/New_York',
+ );
+ foreach ($timezones as $timezone) {
+ $dates = array(
+ 'small' => format_date($time, 'small', '', $timezone),
+ 'medium' => format_date($time, 'medium', '', $timezone),
+ 'large' => format_date($time, 'large', '', $timezone),
+ 'custom' => format_date($time, 'custom', 'c', $timezone),
+ );
+ $this->assertRenderedDatesEqual($view, $dates, $timezone);
+ }
+
+ $intervals = array(
'raw time ago' => format_interval(REQUEST_TIME - $time, 2),
'time ago' => t('%time ago', array('%time' => format_interval(REQUEST_TIME - $time, 2))),
// TODO write tests for them
// 'raw time span' => format_interval(REQUEST_TIME - $time, 2),
// 'time span' => t('%time hence', array('%time' => format_interval(REQUEST_TIME - $time, 2))),
);
+ $this->assertRenderedDatesEqual($view, $intervals);
+ }
- $this->executeView($view);
-
- foreach ($maps as $date_format => $expected_result) {
+ protected function assertRenderedDatesEqual($view, $map, $timezone = NULL) {
+ foreach ($map as $date_format => $expected_result) {
$view->field['created']->options['date_format'] = $date_format;
- $this->assertEqual($expected_result, $view->field['created']->advanced_render($view->result[0]));
- debug($view->field['created']->advanced_render($view->result[0]));
+ $t_args = array(
+ '%value' => $expected_result,
+ '%format' => $date_format,
+ );
+ if (isset($timezone)) {
+ $t_args['%timezone'] = $timezone;
+ $message = t('Value %value in %format format for timezone %timezone matches.', $t_args);
+ $view->field['created']->options['timezone'] = $timezone;
+ }
+ else {
+ $message = t('Value %value in %format format matches.', $t_args);
+ }
+ $actual_result = $view->field['created']->advanced_render($view->result[0]);
+ $this->assertEqual($expected_result, $actual_result, $message);
}
- debug($view->result);
}
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_file_size.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_file_size.test
index ae2569e..8652754 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_file_size.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_file_size.test
@@ -1,6 +1,13 @@
<?php
/**
+ * @file
+ * Definition of ViewsHandlerTestFileSize.
+ */
+
+/**
+ * Tests the core views_handler_field_file_size handler.
+ *
* @see CommonXssUnitTest
*/
class ViewsHandlerTestFileSize extends ViewsSqlTest {
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_math.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_math.test
index 2d222e6..ac33ac4 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_math.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_math.test
@@ -1,5 +1,13 @@
<?php
+/**
+ * @file
+ * Definition of ViewsHandlerFieldMath.
+ */
+
+/**
+ * Tests the core views_handler_field_math handler.
+ */
class ViewsHandlerFieldMath extends ViewsSqlTest {
public static function getInfo() {
return array(
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_url.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_url.test
index 35bffa7..527e94f 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_url.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_url.test
@@ -1,5 +1,13 @@
<?php
+/**
+ * @file
+ * Definition of ViewsHandlerFieldUrlTest.
+ */
+
+/**
+ * Tests the core views_handler_field_url handler.
+ */
class ViewsHandlerFieldUrlTest extends ViewsSqlTest {
public static function getInfo() {
return array(
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_xss.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_xss.test
index c76d188..65a1ce2 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_xss.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_field_xss.test
@@ -1,6 +1,13 @@
<?php
/**
+ * @file
+ * Definition of ViewsHandlerTestXss.
+ */
+
+/**
+ * Tests the core views_handler_field_css handler.
+ *
* @see CommonXssUnitTest
*/
class ViewsHandlerTestXss extends ViewsSqlTest {
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_combine.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_combine.test
new file mode 100644
index 0000000..99bf1eb
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_combine.test
@@ -0,0 +1,105 @@
+<?php
+
+/**
+ * @file
+ * Definition of ViewsHandlerFilterCombineTest.
+ */
+
+/**
+ * Tests the combine filter handler.
+ */
+class ViewsHandlerFilterCombineTest extends ViewsSqlTest {
+ var $column_map = array();
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Filter: Combine',
+ 'description' => 'Tests the combine filter handler.',
+ 'group' => 'Views Handlers',
+ );
+ }
+
+ function setUp() {
+ parent::setUp();
+ $this->column_map = array(
+ 'views_test_name' => 'name',
+ 'views_test_job' => 'job',
+ );
+ }
+
+ protected function getBasicView() {
+ $view = parent::getBasicView();
+ $fields = $view->display['default']->handler->options['fields'];
+ $view->display['default']->display_options['fields']['job'] = array(
+ 'id' => 'job',
+ 'table' => 'views_test',
+ 'field' => 'job',
+ 'relationship' => 'none',
+ );
+ return $view;
+ }
+
+ public function testFilterCombineContains() {
+ $view = $this->getBasicView();
+
+ // Change the filtering.
+ $view->display['default']->handler->override_option('filters', array(
+ 'age' => array(
+ 'id' => 'combine',
+ 'table' => 'views',
+ 'field' => 'combine',
+ 'relationship' => 'none',
+ 'operator' => 'contains',
+ 'fields' => array(
+ 'name',
+ 'job',
+ ),
+ 'value' => 'ing',
+ ),
+ ));
+
+ $this->executeView($view);
+ $resultset = array(
+ array(
+ 'name' => 'John',
+ 'job' => 'Singer',
+ ),
+ array(
+ 'name' => 'George',
+ 'job' => 'Singer',
+ ),
+ array(
+ 'name' => 'Ringo',
+ 'job' => 'Drummer',
+ ),
+ array(
+ 'name' => 'Ginger',
+ 'job' => NULL,
+ ),
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
+ /**
+ * Additional data to test the NULL issue.
+ */
+ protected function dataSet() {
+ $data_set = parent::dataSet();
+ $data_set[] = array(
+ 'name' => 'Ginger',
+ 'age' => 25,
+ 'job' => NULL,
+ 'created' => gmmktime(0, 0, 0, 1, 2, 2000),
+ );
+ return $data_set;
+ }
+
+ /**
+ * Allow {views_test}.job to be NULL.
+ */
+ protected function schemaDefinition() {
+ $schema = parent::schemaDefinition();
+ unset($schema['views_test']['fields']['job']['not null']);
+ return $schema;
+ }
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_date.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_date.test
index 135ce4f..34ccba6 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_date.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_date.test
@@ -1,7 +1,12 @@
<?php
/**
- * Tests the handler filter_date.
+ * @file
+ * Definition of ViewsHandlerFilterDateTest.
+ */
+
+/**
+ * Tests the core views_handler_filter_date handler.
*/
class ViewsHandlerFilterDateTest extends ViewsSqlTest {
public static function getInfo() {
@@ -28,7 +33,7 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest {
}
/**
- /* Test the general offset functionality.
+ * Test the general offset functionality.
*/
function testOffset() {
$view = $this->views_test_offset();
@@ -62,7 +67,7 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest {
/**
- * Test the filter operator between/not between.
+ * Tests the filter operator between/not between.
*/
function testBetween() {
// Test between with min and max.
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_equality.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_equality.test
index 96e82aa..5bb48c8 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_equality.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_equality.test
@@ -1,5 +1,13 @@
<?php
+/**
+ * @file
+ * Definition of ViewsHandlerFilterEqualityTest.
+ */
+
+/**
+ * Tests the core views_handler_filter_equality handler.
+ */
class ViewsHandlerFilterEqualityTest extends ViewsSqlTest {
public static function getInfo() {
return array(
@@ -47,6 +55,24 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+ public function testEqualGroupedExposed() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Name, Operator: =, Value: Ringo
+ $filters['name']['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',
+ ),
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
function testNotEqual() {
$view = $this->getBasicView();
@@ -79,4 +105,69 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest {
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+
+ public function testEqualGroupedNotExposed() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Name, Operator: !=, Value: Ringo
+ $filters['name']['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' => 'John',
+ ),
+ array(
+ 'name' => 'George',
+ ),
+ array(
+ 'name' => 'Paul',
+ ),
+ array(
+ 'name' => 'Meredith',
+ ),
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
+
+ protected function getGroupedExposedFilters() {
+ $filters = array(
+ 'name' => array(
+ 'id' => 'name',
+ 'table' => 'views_test',
+ 'field' => 'name',
+ 'relationship' => 'none',
+ 'exposed' => TRUE,
+ 'expose' => array(
+ 'operator' => 'name_op',
+ 'label' => 'name',
+ 'identifier' => 'name',
+ ),
+ 'is_grouped' => TRUE,
+ 'group_info' => array(
+ 'label' => 'name',
+ 'identifier' => 'name',
+ 'default_group' => 'All',
+ 'group_items' => array(
+ 1 => array(
+ 'title' => 'Name is equal to Ringo',
+ 'operator' => '=',
+ 'value' => array('value' => 'Ringo'),
+ ),
+ 2 => array(
+ 'title' => 'Name is not equal to Ringo',
+ 'operator' => '!=',
+ 'value' => array('value' => 'Ringo'),
+ ),
+ ),
+ ),
+ ),
+ );
+ return $filters;
+ }
+
}
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;
+ }
+
}
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;
+ }
+
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_string.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_string.test
index cd78311..ee74a28 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_string.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_filter_string.test
@@ -1,5 +1,13 @@
<?php
+/**
+ * @file
+ * Definition of ViewsHandlerFilterStringTest.
+ */
+
+/**
+ * Tests the core views_handler_filter_string handler.
+ */
class ViewsHandlerFilterStringTest extends ViewsSqlTest {
var $column_map = array();
@@ -86,9 +94,29 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
- $view->destroy();
+ }
+
+ function testFilterStringGroupedExposedEqual() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Name, Operator: =, Value: Ringo
+ $filters['name']['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',
+ ),
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+ function testFilterStringNotEqual() {
$view = $this->getBasicView();
// Change the filtering
@@ -121,6 +149,36 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+ function testFilterStringGroupedExposedNotEqual() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Name, Operator: !=, Value: Ringo
+ $filters['name']['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' => 'John',
+ ),
+ array(
+ 'name' => 'George',
+ ),
+ array(
+ 'name' => 'Paul',
+ ),
+ array(
+ 'name' => 'Meredith',
+ ),
+ );
+
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
function testFilterStringContains() {
$view = $this->getBasicView();
@@ -145,6 +203,28 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+
+ function testFilterStringGroupedExposedContains() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Name, Operator: contains, Value: ing
+ $filters['name']['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' => 'Ringo',
+ ),
+ );
+
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
+
function testFilterStringWord() {
$view = $this->getBasicView();
@@ -195,6 +275,47 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+
+ function testFilterStringGroupedExposedWord() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Name, Operator: contains, Value: ing
+ $filters['name']['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' => 'Ringo',
+ ),
+ );
+
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ $view->destroy();
+
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Description, Operator: contains, Value: actor
+ $filters['description']['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' => 'George',
+ ),
+ array(
+ 'name' => 'Ringo',
+ ),
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
function testFilterStringStarts() {
$view = $this->getBasicView();
@@ -219,6 +340,25 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+ function testFilterStringGroupedExposedStarts() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Name, Operator: starts, Value: George
+ $filters['description']['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',
+ ),
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
function testFilterStringNotStarts() {
$view = $this->getBasicView();
@@ -250,6 +390,32 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+ function testFilterStringGroupedExposedNotStarts() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Name, Operator: not_starts, Value: George
+ $filters['description']['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',
+ ),
+ array(
+ 'name' => 'Ringo',
+ ),
+ array(
+ 'name' => 'Paul',
+ ),
+ // There is no Meredith returned because his description is empty
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
function testFilterStringEnds() {
$view = $this->getBasicView();
@@ -277,6 +443,28 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+ function testFilterStringGroupedExposedEnds() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Descriptino, Operator: ends, Value: Beatles
+ $filters['description']['group_info']['default_group'] = 4;
+ $view->set_display('page_1');
+ $view->display['page_1']->handler->override_option('filters', $filters);
+
+ $this->executeView($view);
+
+ $resultset = array(
+ array(
+ 'name' => 'George',
+ ),
+ array(
+ 'name' => 'Ringo',
+ ),
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
function testFilterStringNotEnds() {
$view = $this->getBasicView();
@@ -305,6 +493,29 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+ function testFilterStringGroupedExposedNotEnds() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Description, Operator: not_ends, Value: Beatles
+ $filters['description']['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',
+ ),
+ array(
+ 'name' => 'Paul',
+ ),
+ // There is no Meredith returned because his description is empty
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
function testFilterStringNot() {
$view = $this->getBasicView();
@@ -333,6 +544,31 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+
+ function testFilterStringGroupedExposedNot() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Description, Operator: not (does not contains), Value: Beatles
+ $filters['description']['group_info']['default_group'] = 6;
+ $view->set_display('page_1');
+ $view->display['page_1']->handler->override_option('filters', $filters);
+
+ $this->executeView($view);
+
+ $resultset = array(
+ array(
+ 'name' => 'John',
+ ),
+ array(
+ 'name' => 'Paul',
+ ),
+ // There is no Meredith returned because his description is empty
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+
+ }
+
function testFilterStringShorter() {
$view = $this->getBasicView();
@@ -360,6 +596,27 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+ function testFilterStringGroupedExposedShorter() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Name, Operator: shorterthan, Value: 5
+ $filters['name']['group_info']['default_group'] = 4;
+ $view->set_display('page_1');
+ $view->display['page_1']->handler->override_option('filters', $filters);
+
+ $this->executeView($view);
+ $resultset = array(
+ array(
+ 'name' => 'John',
+ ),
+ array(
+ 'name' => 'Paul',
+ ),
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
function testFilterStringLonger() {
$view = $this->getBasicView();
@@ -384,6 +641,25 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+ function testFilterStringGroupedExposedLonger() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Name, Operator: longerthan, Value: 4
+ $filters['name']['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' => 'Meredith',
+ ),
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
+
function testFilterStringEmpty() {
$view = $this->getBasicView();
@@ -406,4 +682,129 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
}
+
+ function testFilterStringGroupedExposedEmpty() {
+ $filters = $this->getGroupedExposedFilters();
+ $view = $this->getBasicPageView();
+
+ // Filter: Description, Operator: empty, Value:
+ $filters['description']['group_info']['default_group'] = 7;
+ $view->set_display('page_1');
+ $view->display['page_1']->handler->override_option('filters', $filters);
+
+ $this->executeView($view);
+ $resultset = array(
+ array(
+ 'name' => 'Meredith',
+ ),
+ );
+ $this->assertIdenticalResultset($view, $resultset, $this->column_map);
+ }
+
+ protected function getGroupedExposedFilters() {
+ $filters = array(
+ 'name' => array(
+ 'id' => 'name',
+ 'table' => 'views_test',
+ 'field' => 'name',
+ 'relationship' => 'none',
+ 'exposed' => TRUE,
+ 'expose' => array(
+ 'operator' => 'name_op',
+ 'label' => 'name',
+ 'identifier' => 'name',
+ ),
+ 'is_grouped' => TRUE,
+ 'group_info' => array(
+ 'label' => 'name',
+ 'identifier' => 'name',
+ 'default_group' => 'All',
+ 'group_items' => array(
+ 1 => array(
+ 'title' => 'Is Ringo',
+ 'operator' => '=',
+ 'value' => 'Ringo',
+ ),
+ 2 => array(
+ 'title' => 'Is not Ringo',
+ 'operator' => '!=',
+ 'value' => array('value' => 'Ringo'),
+ ),
+ 3 => array(
+ 'title' => 'Contains ing',
+ 'operator' => 'contains',
+ 'value' => 'ing',
+ ),
+ 4 => array(
+ 'title' => 'Shorter than 5 letters',
+ 'operator' => 'shorterthan',
+ 'value' => 5,
+ ),
+ 5 => array(
+ 'title' => 'Longer than 7 letters',
+ 'operator' => 'longerthan',
+ 'value' => 7,
+ ),
+ ),
+ ),
+ ),
+ 'description' => array(
+ 'id' => 'description',
+ 'table' => 'views_test',
+ 'field' => 'description',
+ 'relationship' => 'none',
+ 'exposed' => TRUE,
+ 'expose' => array(
+ 'operator' => 'description_op',
+ 'label' => 'description',
+ 'identifier' => 'description',
+ ),
+ 'is_grouped' => TRUE,
+ 'group_info' => array(
+ 'label' => 'description',
+ 'identifier' => 'description',
+ 'default_group' => 'All',
+ 'group_items' => array(
+ 1 => array(
+ 'title' => 'Contains the word: Actor',
+ 'operator' => 'word',
+ 'value' => 'actor',
+ ),
+ 2 => array(
+ 'title' => 'Starts with George',
+ 'operator' => 'starts',
+ 'value' => 'George',
+ ),
+ 3 => array(
+ 'title' => 'Not Starts with: George',
+ 'operator' => 'not_starts',
+ 'value' => 'George',
+ ),
+ 4 => array(
+ 'title' => 'Ends with: Beatles',
+ 'operator' => 'ends',
+ 'value' => 'Beatles.',
+ ),
+ 5 => array(
+ 'title' => 'Not Ends with: Beatles',
+ 'operator' => 'not_ends',
+ 'value' => 'Beatles.',
+ ),
+ 6 => array(
+ 'title' => 'Does not contain: Beatles',
+ 'operator' => 'not',
+ 'value' => 'Beatles.',
+ ),
+ 7 => array(
+ 'title' => 'Empty description',
+ 'operator' => 'empty',
+ 'value' => '',
+ ),
+ ),
+ ),
+ ),
+ );
+ return $filters;
+ }
+
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort.test
index aa63a9a..70f2aac 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort.test
@@ -1,7 +1,12 @@
<?php
/**
- * Test for core views_handler_sort handler.
+ * @file
+ * Definition of ViewsHandlerSortTest.
+ */
+
+/**
+ * Tests for core views_handler_sort handler.
*/
class ViewsHandlerSortTest extends ViewsSqlTest {
public static function getInfo() {
@@ -13,7 +18,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest {
}
/**
- * Test numeric ordering of the result set.
+ * Tests numeric ordering of the result set.
*/
public function testNumericOrdering() {
$view = $this->getBasicView();
@@ -64,7 +69,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest {
}
/**
- * Test string ordering of the result set.
+ * Tests string ordering of the result set.
*/
public function testStringOrdering() {
$view = $this->getBasicView();
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort_date.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort_date.test
index 528c85a..65a94e8 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort_date.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort_date.test
@@ -1,7 +1,12 @@
<?php
/**
- * Test for core views_handler_sort_date handler.
+ * @file
+ * Definition of ViewsHandlerSortDateTest.
+ */
+
+/**
+ * Tests for core views_handler_sort_date handler.
*/
class ViewsHandlerSortDateTest extends ViewsSqlTest {
public static function getInfo() {
@@ -135,7 +140,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest {
}
/**
- * Test numeric ordering of the result set.
+ * Tests numeric ordering of the result set.
*/
public function testDateOrdering() {
foreach (array('second', 'minute', 'hour', 'day', 'month', 'year') as $granularity) {
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort_random.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort_random.test
index 18677a0..19db8a9 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort_random.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/handlers/views_handler_sort_random.test
@@ -1,7 +1,12 @@
<?php
/**
- * Test for core views_handler_sort_random handler.
+ * @file
+ * Definition of ViewsHandlerSortRandomTest.
+ */
+
+/**
+ * Tests for core views_handler_sort_random handler.
*/
class ViewsHandlerSortRandomTest extends ViewsSqlTest {
public static function getInfo() {
@@ -47,9 +52,9 @@ class ViewsHandlerSortRandomTest extends ViewsSqlTest {
}
/**
- * Test random ordering of the result set.
+ * Tests random ordering of the result set.
*
- * @see DatabaseSelectTestCase::testRandomOrder().
+ * @see DatabaseSelectTestCase::testRandomOrder()
*/
public function testRandomOrdering() {
// Execute a basic view first.