1 |
78d68095
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Definition of ViewsHandlerFilterTest.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Tests filter handler.
|
10 |
|
|
*/
|
11 |
|
|
class ViewsHandlerFilterTest extends ViewsSqlTest {
|
12 |
|
|
|
13 |
|
|
/**
|
14 |
|
|
* {@inheritdoc}
|
15 |
|
|
*/
|
16 |
|
|
public static function getInfo() {
|
17 |
|
|
return array(
|
18 |
|
|
'name' => 'Handler filter test',
|
19 |
|
|
'description' => 'test filter handler definitions',
|
20 |
|
|
'group' => 'Views',
|
21 |
|
|
);
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
/**
|
25 |
|
|
* {@inheritdoc}
|
26 |
|
|
*/
|
27 |
4003efde
|
Assos Assos
|
public function setUp(array $modules = array()) {
|
28 |
|
|
parent::setUp($modules);
|
29 |
78d68095
|
Assos Assos
|
|
30 |
|
|
// Assign vocabulary 'tag' to user entity.
|
31 |
|
|
$field_definition = field_read_field('field_tags');
|
32 |
|
|
$instance_definition = array(
|
33 |
|
|
'field_name' => $field_definition['field_name'],
|
34 |
|
|
'entity_type' => 'user',
|
35 |
|
|
'bundle' => 'user',
|
36 |
|
|
'widget' => array(
|
37 |
|
|
'type' => 'taxonomy_autocomplete',
|
38 |
|
|
),
|
39 |
|
|
'display' => array(
|
40 |
|
|
'default' => array(
|
41 |
|
|
'type' => 'taxonomy_term_reference_link',
|
42 |
|
|
'weight' => 10,
|
43 |
|
|
),
|
44 |
|
|
'teaser' => array(
|
45 |
|
|
'type' => 'taxonomy_term_reference_link',
|
46 |
|
|
'weight' => 10,
|
47 |
|
|
),
|
48 |
|
|
),
|
49 |
|
|
);
|
50 |
|
|
field_create_instance($instance_definition);
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
/**
|
54 |
|
|
* Tests "is all of" of filter operation.
|
55 |
|
|
*/
|
56 |
|
|
function testFilterInOperatorUi() {
|
57 |
|
|
$term = $this->drupalCreateTerm(1);
|
58 |
|
|
|
59 |
|
|
$node1 = $this->drupalCreateNode(array('type' => 'article','field_tags_tid' => $term->tid, 'created' => REQUEST_TIME));
|
60 |
|
|
$node2 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME + 1));
|
61 |
|
|
$user2 = $this->drupalCreateUser(array('access content'));
|
62 |
6de61b86
|
Assos Assos
|
// $this->drupalLogin($this->drupalCreateUser(array('administer users'));
|
63 |
|
|
$this->drupalLogin($this->drupalCreateUser(array('administer users', 'access administration pages', 'administer site configuration', 'administer nodes', 'bypass node access')));
|
64 |
78d68095
|
Assos Assos
|
|
65 |
|
|
$this->drupalGet('node/1/edit');
|
66 |
|
|
$edit['field_tags' . '[' . LANGUAGE_NONE . ']'] = $term->name;
|
67 |
|
|
$this->drupalPost('node/' . $node1->nid . '/edit', $edit, t('Save'));
|
68 |
|
|
|
69 |
|
|
$edit['field_tags' . '[' . LANGUAGE_NONE . ']'] = $term->name;
|
70 |
|
|
$this->drupalPost('user/' . $user2->uid . '/edit', $edit, t('Save'));
|
71 |
|
|
|
72 |
|
|
$result[] = array('nid' => $node1->nid);
|
73 |
|
|
$view = $this->get_sample_view();
|
74 |
|
|
$this->executeView($view);
|
75 |
|
|
$this->assertIdenticalResultset($view, $result);
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
/**
|
79 |
|
|
* Sample view.
|
80 |
|
|
*
|
81 |
|
|
* @return \view
|
82 |
|
|
*/
|
83 |
|
|
protected function get_sample_view() {
|
84 |
|
|
$view = new view();
|
85 |
|
|
$view->name = 'article';
|
86 |
|
|
$view->description = '';
|
87 |
|
|
$view->tag = 'default';
|
88 |
|
|
$view->base_table = 'node';
|
89 |
|
|
$view->human_name = 'Article';
|
90 |
|
|
$view->core = 7;
|
91 |
|
|
$view->api_version = '3.0';
|
92 |
|
|
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
93 |
|
|
|
94 |
|
|
/* Display: Master */
|
95 |
|
|
$handler = $view->new_display('default', 'Master', 'default');
|
96 |
|
|
$handler->display->display_options['title'] = 'Article';
|
97 |
|
|
$handler->display->display_options['use_more_always'] = FALSE;
|
98 |
|
|
$handler->display->display_options['access']['type'] = 'perm';
|
99 |
|
|
$handler->display->display_options['cache']['type'] = 'none';
|
100 |
|
|
$handler->display->display_options['query']['type'] = 'views_query';
|
101 |
|
|
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
102 |
|
|
$handler->display->display_options['pager']['type'] = 'full';
|
103 |
|
|
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
|
104 |
|
|
$handler->display->display_options['style_plugin'] = 'table';
|
105 |
|
|
$handler->display->display_options['style_options']['columns'] = array(
|
106 |
|
|
'title' => 'title',
|
107 |
|
|
);
|
108 |
|
|
$handler->display->display_options['style_options']['default'] = '-1';
|
109 |
|
|
$handler->display->display_options['style_options']['info'] = array(
|
110 |
|
|
'title' => array(
|
111 |
|
|
'sortable' => 0,
|
112 |
|
|
'default_sort_order' => 'asc',
|
113 |
|
|
'align' => '',
|
114 |
|
|
'separator' => '',
|
115 |
|
|
'empty_column' => 0,
|
116 |
|
|
),
|
117 |
|
|
);
|
118 |
|
|
/* Field: Content: Nid */
|
119 |
|
|
$handler->display->display_options['fields']['nid']['id'] = 'nid';
|
120 |
|
|
$handler->display->display_options['fields']['nid']['table'] = 'node';
|
121 |
|
|
$handler->display->display_options['fields']['nid']['field'] = 'nid';
|
122 |
|
|
$handler->display->display_options['fields']['nid']['label'] = '';
|
123 |
|
|
$handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE;
|
124 |
|
|
/* Sort criterion: Content: Post date */
|
125 |
|
|
$handler->display->display_options['sorts']['created']['id'] = 'created';
|
126 |
|
|
$handler->display->display_options['sorts']['created']['table'] = 'node';
|
127 |
|
|
$handler->display->display_options['sorts']['created']['field'] = 'created';
|
128 |
|
|
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
|
129 |
|
|
/* Filter criterion: Content: Published */
|
130 |
|
|
$handler->display->display_options['filters']['status']['id'] = 'status';
|
131 |
|
|
$handler->display->display_options['filters']['status']['table'] = 'node';
|
132 |
|
|
$handler->display->display_options['filters']['status']['field'] = 'status';
|
133 |
|
|
$handler->display->display_options['filters']['status']['value'] = 1;
|
134 |
|
|
$handler->display->display_options['filters']['status']['group'] = 1;
|
135 |
|
|
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
136 |
|
|
/* Filter criterion: Field: Tags (field_tags) */
|
137 |
|
|
$handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid';
|
138 |
|
|
$handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags';
|
139 |
|
|
$handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid';
|
140 |
|
|
$handler->display->display_options['filters']['field_tags_tid']['operator'] = 'and';
|
141 |
|
|
$handler->display->display_options['filters']['field_tags_tid']['value'] = array(
|
142 |
|
|
0 => '1',
|
143 |
|
|
);
|
144 |
|
|
$handler->display->display_options['filters']['field_tags_tid']['expose']['operator_id'] = 'field_tags_tid_op';
|
145 |
|
|
$handler->display->display_options['filters']['field_tags_tid']['expose']['label'] = 'Tags (field_tags)';
|
146 |
|
|
$handler->display->display_options['filters']['field_tags_tid']['expose']['operator'] = 'field_tags_tid_op';
|
147 |
|
|
$handler->display->display_options['filters']['field_tags_tid']['expose']['identifier'] = 'field_tags_tid';
|
148 |
|
|
$handler->display->display_options['filters']['field_tags_tid']['expose']['remember_roles'] = array(
|
149 |
|
|
2 => '2',
|
150 |
|
|
);
|
151 |
|
|
$handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags';
|
152 |
|
|
|
153 |
|
|
/* Display: Page */
|
154 |
|
|
$handler = $view->new_display('page', 'Page', 'page');
|
155 |
|
|
$handler->display->display_options['path'] = 'article';
|
156 |
|
|
|
157 |
|
|
return $view;
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
} |