1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of ViewsUserTestCase.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Tests basic user module integration into views.
|
10
|
*/
|
11
|
class ViewsUserTestCase extends ViewsSqlTest {
|
12
|
|
13
|
/**
|
14
|
*
|
15
|
*/
|
16
|
var $users = array();
|
17
|
|
18
|
/**
|
19
|
*
|
20
|
*/
|
21
|
var $nodes = array();
|
22
|
|
23
|
/**
|
24
|
*
|
25
|
*/
|
26
|
public static function getInfo() {
|
27
|
return array(
|
28
|
'name' => 'Tests basic user integration',
|
29
|
'description' => 'Tests the integration of user module',
|
30
|
'group' => 'Views Modules',
|
31
|
);
|
32
|
}
|
33
|
|
34
|
/**
|
35
|
*
|
36
|
*/
|
37
|
public function setUp(array $modules = array()) {
|
38
|
parent::setUp($modules);
|
39
|
|
40
|
$this->users[] = $this->drupalCreateUser();
|
41
|
$this->users[] = user_load(1);
|
42
|
$this->nodes[] = $this->drupalCreateNode(array('uid' => $this->users[0]->uid));
|
43
|
$this->nodes[] = $this->drupalCreateNode(array('uid' => 1));
|
44
|
}
|
45
|
|
46
|
/**
|
47
|
* Add a view which has no explicit relationship to the author.
|
48
|
*
|
49
|
* @todo: Remove the following comment once the relationship is required.
|
50
|
* One day a view will require the relationship so it should still work
|
51
|
*/
|
52
|
public function testRelationship() {
|
53
|
$view = $this->test_view_user_relationship();
|
54
|
|
55
|
$view->execute_display();
|
56
|
$expected = array();
|
57
|
for ($i = 0; $i <= 1; $i++) {
|
58
|
$expected[$i] = array(
|
59
|
'node_title' => $this->nodes[$i]->title,
|
60
|
'users_uid' => $this->nodes[$i]->uid,
|
61
|
'users_name' => $this->users[$i]->name,
|
62
|
);
|
63
|
}
|
64
|
$this->assertIdenticalResultset($view, $expected);
|
65
|
}
|
66
|
|
67
|
/**
|
68
|
*
|
69
|
*/
|
70
|
function test_view_user_relationship() {
|
71
|
$view = new view();
|
72
|
$view->name = 'test_user_relationship';
|
73
|
$view->description = '';
|
74
|
$view->tag = 'default';
|
75
|
$view->base_table = 'node';
|
76
|
$view->human_name = 'test_user_relationship';
|
77
|
$view->core = 7;
|
78
|
$view->api_version = '3.0-alpha1';
|
79
|
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
80
|
|
81
|
/* Display: Master */
|
82
|
$handler = $view->new_display('default', 'Master', 'default');
|
83
|
$handler->display->display_options['title'] = 'test_user_relationship';
|
84
|
$handler->display->display_options['access']['type'] = 'perm';
|
85
|
$handler->display->display_options['cache']['type'] = 'none';
|
86
|
$handler->display->display_options['query']['type'] = 'views_query';
|
87
|
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
|
88
|
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
89
|
$handler->display->display_options['pager']['type'] = 'full';
|
90
|
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
|
91
|
$handler->display->display_options['style_plugin'] = 'default';
|
92
|
$handler->display->display_options['row_plugin'] = 'fields';
|
93
|
$handler->display->display_options['row_options']['hide_empty'] = 0;
|
94
|
$handler->display->display_options['row_options']['default_field_elements'] = 1;
|
95
|
/* Field: Content: Title */
|
96
|
$handler->display->display_options['fields']['title']['id'] = 'title';
|
97
|
$handler->display->display_options['fields']['title']['table'] = 'node';
|
98
|
$handler->display->display_options['fields']['title']['field'] = 'title';
|
99
|
$handler->display->display_options['fields']['title']['label'] = '';
|
100
|
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
|
101
|
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
|
102
|
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
|
103
|
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
|
104
|
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
|
105
|
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
|
106
|
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
|
107
|
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
|
108
|
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
|
109
|
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
|
110
|
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
|
111
|
/* Field: User: Name */
|
112
|
$handler->display->display_options['fields']['name']['id'] = 'name';
|
113
|
$handler->display->display_options['fields']['name']['table'] = 'users';
|
114
|
$handler->display->display_options['fields']['name']['field'] = 'name';
|
115
|
$handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
|
116
|
$handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
|
117
|
$handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
|
118
|
$handler->display->display_options['fields']['name']['alter']['external'] = 0;
|
119
|
$handler->display->display_options['fields']['name']['alter']['replace_spaces'] = 0;
|
120
|
$handler->display->display_options['fields']['name']['alter']['trim_whitespace'] = 0;
|
121
|
$handler->display->display_options['fields']['name']['alter']['nl2br'] = 0;
|
122
|
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = 1;
|
123
|
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = 1;
|
124
|
$handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
|
125
|
$handler->display->display_options['fields']['name']['alter']['trim'] = 0;
|
126
|
$handler->display->display_options['fields']['name']['alter']['html'] = 0;
|
127
|
$handler->display->display_options['fields']['name']['element_label_colon'] = 1;
|
128
|
$handler->display->display_options['fields']['name']['element_default_classes'] = 1;
|
129
|
$handler->display->display_options['fields']['name']['hide_empty'] = 0;
|
130
|
$handler->display->display_options['fields']['name']['empty_zero'] = 0;
|
131
|
$handler->display->display_options['fields']['name']['hide_alter_empty'] = 0;
|
132
|
$handler->display->display_options['fields']['name']['link_to_user'] = 1;
|
133
|
$handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
|
134
|
/* Field: User: Uid */
|
135
|
$handler->display->display_options['fields']['uid']['id'] = 'uid';
|
136
|
$handler->display->display_options['fields']['uid']['table'] = 'users';
|
137
|
$handler->display->display_options['fields']['uid']['field'] = 'uid';
|
138
|
$handler->display->display_options['fields']['uid']['alter']['alter_text'] = 0;
|
139
|
$handler->display->display_options['fields']['uid']['alter']['make_link'] = 0;
|
140
|
$handler->display->display_options['fields']['uid']['alter']['absolute'] = 0;
|
141
|
$handler->display->display_options['fields']['uid']['alter']['external'] = 0;
|
142
|
$handler->display->display_options['fields']['uid']['alter']['replace_spaces'] = 0;
|
143
|
$handler->display->display_options['fields']['uid']['alter']['trim_whitespace'] = 0;
|
144
|
$handler->display->display_options['fields']['uid']['alter']['nl2br'] = 0;
|
145
|
$handler->display->display_options['fields']['uid']['alter']['word_boundary'] = 1;
|
146
|
$handler->display->display_options['fields']['uid']['alter']['ellipsis'] = 1;
|
147
|
$handler->display->display_options['fields']['uid']['alter']['strip_tags'] = 0;
|
148
|
$handler->display->display_options['fields']['uid']['alter']['trim'] = 0;
|
149
|
$handler->display->display_options['fields']['uid']['alter']['html'] = 0;
|
150
|
$handler->display->display_options['fields']['uid']['element_label_colon'] = 1;
|
151
|
$handler->display->display_options['fields']['uid']['element_default_classes'] = 1;
|
152
|
$handler->display->display_options['fields']['uid']['hide_empty'] = 0;
|
153
|
$handler->display->display_options['fields']['uid']['empty_zero'] = 0;
|
154
|
$handler->display->display_options['fields']['uid']['hide_alter_empty'] = 0;
|
155
|
$handler->display->display_options['fields']['uid']['link_to_user'] = 1;
|
156
|
|
157
|
return $view;
|
158
|
}
|
159
|
|
160
|
}
|