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