Project

General

Profile

Paste
Download (2.37 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / views / tests / handlers / views_handler_filter_combine.test @ 4003efde

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of ViewsHandlerFilterCombineTest.
6
 */
7

    
8
/**
9
 * Tests the combine filter handler.
10
 */
11
class ViewsHandlerFilterCombineTest extends ViewsSqlTest {
12
  var $column_map = array();
13

    
14
  public static function getInfo() {
15
    return array(
16
      'name' => 'Filter: Combine',
17
      'description' => 'Tests the combine filter handler.',
18
      'group' => 'Views Handlers',
19
    );
20
  }
21

    
22
  /**
23
   * {@inheritdoc}
24
   */
25
  public function setUp(array $modules = array()) {
26
    parent::setUp($modules);
27

    
28
    $this->column_map = array(
29
      'views_test_name' => 'name',
30
      'views_test_job' => 'job',
31
    );
32
  }
33

    
34
  protected function getBasicView() {
35
    $view = parent::getBasicView();
36
    $fields = $view->display['default']->handler->options['fields'];
37
    $view->display['default']->display_options['fields']['job'] = array(
38
      'id' => 'job',
39
      'table' => 'views_test',
40
      'field' => 'job',
41
      'relationship' => 'none',
42
    );
43
    return $view;
44
  }
45

    
46
  public function testFilterCombineContains() {
47
    $view = $this->getBasicView();
48

    
49
    // Change the filtering.
50
    $view->display['default']->handler->override_option('filters', array(
51
      'age' => array(
52
        'id' => 'combine',
53
        'table' => 'views',
54
        'field' => 'combine',
55
        'relationship' => 'none',
56
        'operator' => 'contains',
57
        'fields' => array(
58
          'name',
59
          'job',
60
        ),
61
        'value' => 'ing',
62
      ),
63
    ));
64

    
65
    $this->executeView($view);
66
    $resultset = array(
67
      array(
68
        'name' => 'John',
69
        'job' => 'Singer',
70
      ),
71
      array(
72
        'name' => 'George',
73
        'job' => 'Singer',
74
      ),
75
      array(
76
        'name' => 'Ringo',
77
        'job' => 'Drummer',
78
      ),
79
      array(
80
        'name' => 'Ginger',
81
        'job' => NULL,
82
      ),
83
    );
84
    $this->assertIdenticalResultset($view, $resultset, $this->column_map);
85
  }
86

    
87
  /**
88
   * Additional data to test the NULL issue.
89
   */
90
  protected function dataSet() {
91
    $data_set = parent::dataSet();
92
    $data_set[] = array(
93
      'name' => 'Ginger',
94
      'age' => 25,
95
      'job' => NULL,
96
      'created' => gmmktime(0, 0, 0, 1, 2, 2000),
97
    );
98
    return $data_set;
99
  }
100

    
101
  /**
102
   * Allow {views_test}.job to be NULL.
103
   */
104
  protected function schemaDefinition() {
105
    $schema = parent::schemaDefinition();
106
    unset($schema['views_test']['fields']['job']['not null']);
107
    return $schema;
108
  }
109

    
110
}