1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of viewsPluginStyleJumpMenuTest.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Tests jump menu style functionality.
|
10
|
*/
|
11
|
class viewsPluginStyleJumpMenuTest extends ViewsSqlTest {
|
12
|
|
13
|
/**
|
14
|
* Stores all created nodes.
|
15
|
*
|
16
|
* @var array
|
17
|
*/
|
18
|
var $nodes;
|
19
|
|
20
|
public static function getInfo() {
|
21
|
return array(
|
22
|
'name' => 'Jump menu',
|
23
|
'description' => 'Test jump menu style functionality.',
|
24
|
'group' => 'Views Plugins',
|
25
|
);
|
26
|
}
|
27
|
|
28
|
|
29
|
public function setUp() {
|
30
|
parent::setUp();
|
31
|
$this->nodes = array();
|
32
|
$this->nodes['page'][] = $this->drupalCreateNode(array('type' => 'page'));
|
33
|
$this->nodes['page'][] = $this->drupalCreateNode(array('type' => 'page'));
|
34
|
$this->nodes['story'][] = $this->drupalCreateNode(array('type' => 'story'));
|
35
|
$this->nodes['story'][] = $this->drupalCreateNode(array('type' => 'story'));
|
36
|
|
37
|
$this->nodeTitles = array($this->nodes['page'][0]->title, $this->nodes['page'][1]->title, $this->nodes['story'][0]->title, $this->nodes['story'][1]->title);
|
38
|
}
|
39
|
|
40
|
|
41
|
/**
|
42
|
* Tests jump menues with more then one same path but maybe differnet titles.
|
43
|
*/
|
44
|
function testDuplicatePaths() {
|
45
|
$view = $this->getJumpMenuView();
|
46
|
$view->set_display();
|
47
|
$view->init_handlers();
|
48
|
|
49
|
// Setup a [path] which would leed to "duplicate" paths, but still the shouldn't be used for grouping.
|
50
|
$view->field['nothing']->options['alter']['text'] = '[path]';
|
51
|
$view->preview();
|
52
|
$form = $view->style_plugin->render($view->result);
|
53
|
|
54
|
// As there is no grouping setup it should be 4 elements.
|
55
|
$this->assertEqual(count($form['jump']['#options']), 4 + 1);
|
56
|
|
57
|
// Check that all titles are part of the form as well.
|
58
|
$options = array_values($form['jump']['#options']);
|
59
|
foreach ($options as $key => $title) {
|
60
|
// The first one is the choose label.
|
61
|
if ($key == 0) {
|
62
|
continue;
|
63
|
}
|
64
|
$this->assertTrue($this->nodeTitles[$key - 1] == trim($title), t('Title @title should appear on the jump list, as we do not filter', array('@title' => $title)));
|
65
|
}
|
66
|
}
|
67
|
|
68
|
function getJumpMenuView() {
|
69
|
$view = new view;
|
70
|
$view->name = 'test_jump_menu';
|
71
|
$view->description = '';
|
72
|
$view->tag = 'default';
|
73
|
$view->base_table = 'node';
|
74
|
$view->human_name = 'test_jump_menu';
|
75
|
$view->core = 7;
|
76
|
$view->api_version = '3.0';
|
77
|
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
78
|
|
79
|
/* Display: Master */
|
80
|
$handler = $view->new_display('default', 'Master', 'default');
|
81
|
$handler->display->display_options['access']['type'] = 'perm';
|
82
|
$handler->display->display_options['cache']['type'] = 'none';
|
83
|
$handler->display->display_options['query']['type'] = 'views_query';
|
84
|
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
|
85
|
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
86
|
$handler->display->display_options['pager']['type'] = 'full';
|
87
|
$handler->display->display_options['style_plugin'] = 'jump_menu';
|
88
|
$handler->display->display_options['style_options']['hide'] = 0;
|
89
|
$handler->display->display_options['style_options']['path'] = 'nothing';
|
90
|
$handler->display->display_options['style_options']['default_value'] = 0;
|
91
|
$handler->display->display_options['row_plugin'] = 'fields';
|
92
|
/* Field: Content: Title */
|
93
|
$handler->display->display_options['fields']['title']['id'] = 'title';
|
94
|
$handler->display->display_options['fields']['title']['table'] = 'node';
|
95
|
$handler->display->display_options['fields']['title']['field'] = 'title';
|
96
|
$handler->display->display_options['fields']['title']['label'] = '';
|
97
|
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
|
98
|
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
|
99
|
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
|
100
|
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
|
101
|
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
|
102
|
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
|
103
|
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
|
104
|
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
|
105
|
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
|
106
|
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
|
107
|
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
|
108
|
/* Field: Content: Type */
|
109
|
$handler->display->display_options['fields']['type']['id'] = 'type';
|
110
|
$handler->display->display_options['fields']['type']['table'] = 'node';
|
111
|
$handler->display->display_options['fields']['type']['field'] = 'type';
|
112
|
$handler->display->display_options['fields']['type']['exclude'] = 1;
|
113
|
/* Field: Global: Custom text */
|
114
|
$handler->display->display_options['fields']['nothing']['id'] = 'nothing';
|
115
|
$handler->display->display_options['fields']['nothing']['table'] = 'views';
|
116
|
$handler->display->display_options['fields']['nothing']['field'] = 'nothing';
|
117
|
$handler->display->display_options['fields']['nothing']['alter']['text'] = '[type]';
|
118
|
$handler->display->display_options['fields']['nothing']['alter']['make_link'] = 0;
|
119
|
$handler->display->display_options['fields']['nothing']['alter']['absolute'] = 0;
|
120
|
$handler->display->display_options['fields']['nothing']['alter']['external'] = 0;
|
121
|
$handler->display->display_options['fields']['nothing']['alter']['replace_spaces'] = 0;
|
122
|
$handler->display->display_options['fields']['nothing']['alter']['trim_whitespace'] = 0;
|
123
|
$handler->display->display_options['fields']['nothing']['alter']['nl2br'] = 0;
|
124
|
$handler->display->display_options['fields']['nothing']['alter']['word_boundary'] = 1;
|
125
|
$handler->display->display_options['fields']['nothing']['alter']['ellipsis'] = 1;
|
126
|
$handler->display->display_options['fields']['nothing']['alter']['strip_tags'] = 0;
|
127
|
$handler->display->display_options['fields']['nothing']['alter']['trim'] = 0;
|
128
|
$handler->display->display_options['fields']['nothing']['alter']['html'] = 0;
|
129
|
$handler->display->display_options['fields']['nothing']['element_label_colon'] = 1;
|
130
|
$handler->display->display_options['fields']['nothing']['element_default_classes'] = 1;
|
131
|
$handler->display->display_options['fields']['nothing']['hide_empty'] = 0;
|
132
|
$handler->display->display_options['fields']['nothing']['empty_zero'] = 0;
|
133
|
$handler->display->display_options['fields']['nothing']['hide_alter_empty'] = 0;
|
134
|
$handler->display->display_options['fields']['nothing']['exclude'] = 1;
|
135
|
|
136
|
/* Sort criterion: Content: Post date */
|
137
|
$handler->display->display_options['sorts']['created']['id'] = 'created';
|
138
|
$handler->display->display_options['sorts']['created']['table'] = 'node';
|
139
|
$handler->display->display_options['sorts']['created']['field'] = 'created';
|
140
|
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
|
141
|
/* Filter criterion: Content: Published */
|
142
|
$handler->display->display_options['filters']['status']['id'] = 'status';
|
143
|
$handler->display->display_options['filters']['status']['table'] = 'node';
|
144
|
$handler->display->display_options['filters']['status']['field'] = 'status';
|
145
|
$handler->display->display_options['filters']['status']['value'] = 1;
|
146
|
$handler->display->display_options['filters']['status']['group'] = 0;
|
147
|
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
148
|
|
149
|
return $view;
|
150
|
}
|
151
|
}
|