views_handler_filter_combine.test

Definition of ViewsHandlerFilterCombineTest.

File

tests/handlers/views_handler_filter_combine.test
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of ViewsHandlerFilterCombineTest.
  5. */
  6. /**
  7. * Tests the combine filter handler.
  8. */
  9. class ViewsHandlerFilterCombineTest extends ViewsSqlTest {
  10. var $column_map = array();
  11. public static function getInfo() {
  12. return array(
  13. 'name' => 'Filter: Combine',
  14. 'description' => 'Tests the combine filter handler.',
  15. 'group' => 'Views Handlers',
  16. );
  17. }
  18. function setUp() {
  19. parent::setUp();
  20. $this->column_map = array(
  21. 'views_test_name' => 'name',
  22. 'views_test_job' => 'job',
  23. );
  24. }
  25. protected function getBasicView() {
  26. $view = parent::getBasicView();
  27. $fields = $view->display['default']->handler->options['fields'];
  28. $view->display['default']->display_options['fields']['job'] = array(
  29. 'id' => 'job',
  30. 'table' => 'views_test',
  31. 'field' => 'job',
  32. 'relationship' => 'none',
  33. );
  34. return $view;
  35. }
  36. public function testFilterCombineContains() {
  37. $view = $this->getBasicView();
  38. // Change the filtering.
  39. $view->display['default']->handler->override_option('filters', array(
  40. 'age' => array(
  41. 'id' => 'combine',
  42. 'table' => 'views',
  43. 'field' => 'combine',
  44. 'relationship' => 'none',
  45. 'operator' => 'contains',
  46. 'fields' => array(
  47. 'name',
  48. 'job',
  49. ),
  50. 'value' => 'ing',
  51. ),
  52. ));
  53. $this->executeView($view);
  54. $resultset = array(
  55. array(
  56. 'name' => 'John',
  57. 'job' => 'Singer',
  58. ),
  59. array(
  60. 'name' => 'George',
  61. 'job' => 'Singer',
  62. ),
  63. array(
  64. 'name' => 'Ringo',
  65. 'job' => 'Drummer',
  66. ),
  67. array(
  68. 'name' => 'Ginger',
  69. 'job' => NULL,
  70. ),
  71. );
  72. $this->assertIdenticalResultset($view, $resultset, $this->column_map);
  73. }
  74. /**
  75. * Additional data to test the NULL issue.
  76. */
  77. protected function dataSet() {
  78. $data_set = parent::dataSet();
  79. $data_set[] = array(
  80. 'name' => 'Ginger',
  81. 'age' => 25,
  82. 'job' => NULL,
  83. 'created' => gmmktime(0, 0, 0, 1, 2, 2000),
  84. );
  85. return $data_set;
  86. }
  87. /**
  88. * Allow {views_test}.job to be NULL.
  89. */
  90. protected function schemaDefinition() {
  91. $schema = parent::schemaDefinition();
  92. unset($schema['views_test']['fields']['job']['not null']);
  93. return $schema;
  94. }
  95. }