1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Search tests
|
6
|
*/
|
7
|
|
8
|
class dsSearchTests extends dsBaseTest {
|
9
|
|
10
|
/**
|
11
|
* Implements getInfo().
|
12
|
*/
|
13
|
public static function getInfo() {
|
14
|
return array(
|
15
|
'name' => t('Search'),
|
16
|
'description' => t('Tests for display of search results for nodes and users.'),
|
17
|
'group' => t('Display Suite'),
|
18
|
);
|
19
|
}
|
20
|
|
21
|
function testDSSearch() {
|
22
|
|
23
|
// Create nodes.
|
24
|
$i = 15;
|
25
|
while ($i > 0) {
|
26
|
$settings = array(
|
27
|
'title' => 'title' . $i,
|
28
|
'type' => 'article',
|
29
|
'promote' => 1,
|
30
|
);
|
31
|
$this->drupalCreateNode($settings);
|
32
|
$i--;
|
33
|
}
|
34
|
|
35
|
// Set default search.
|
36
|
$edit = array(
|
37
|
'search_default_module' => 'ds_search',
|
38
|
);
|
39
|
$this->drupalPost('admin/config/search/settings', $edit, t('Save configuration'));
|
40
|
|
41
|
// Run cron.
|
42
|
$this->cronRun();
|
43
|
$this->drupalGet('admin/config/search/settings');
|
44
|
$this->assertText(t('100% of the site has been indexed. There are 0 items left to index.'), 'Site has been indexed');
|
45
|
|
46
|
// Configure search result view mode.
|
47
|
$svm = array('additional_settings[modes][view_modes_custom][search_result]' => 'search_result');
|
48
|
$this->dsConfigureUI($svm);
|
49
|
$layout = array(
|
50
|
'additional_settings[layout]' => 'ds_2col_stacked',
|
51
|
);
|
52
|
$assert = array(
|
53
|
'regions' => array(
|
54
|
'header' => '<td colspan="8">' . t('Header') . '</td>',
|
55
|
'left' => '<td colspan="8">' . t('Left') . '</td>',
|
56
|
'right' => '<td colspan="8">' . t('Right') . '</td>',
|
57
|
'footer' => '<td colspan="8">' . t('Footer') . '</td>',
|
58
|
),
|
59
|
);
|
60
|
$this->dsSelectLayout($layout, $assert, 'admin/structure/types/manage/article/display/search_result');
|
61
|
$fields = array(
|
62
|
'fields[title][region]' => 'header',
|
63
|
'fields[post_date][region]' => 'header',
|
64
|
'fields[author][region]' => 'left',
|
65
|
'fields[body][region]' => 'right',
|
66
|
'fields[node_link][region]' => 'footer',
|
67
|
);
|
68
|
$this->dsConfigureUI($fields, 'admin/structure/types/manage/article/display/search_result');
|
69
|
|
70
|
// Configure ds search.
|
71
|
$edit = array('ds_user_override_search_page' => '1');
|
72
|
$this->drupalPost('admin/structure/ds/list/search', $edit, t('Save configuration'));
|
73
|
|
74
|
// Let's search.
|
75
|
$this->drupalGet('search/content/title1');
|
76
|
$this->assertNoRaw('/search/node/title1');
|
77
|
$this->assertRaw('view-mode-search_result', 'Search view mode found');
|
78
|
$this->assertRaw('group-left', 'Search template found');
|
79
|
$this->assertRaw('group-right', 'Search template found');
|
80
|
$this->assertNoText(t('Advanced search'), 'No advanced search found');
|
81
|
|
82
|
|
83
|
$edit = array('ds_search_node_form_alter' => '1');
|
84
|
$this->drupalPost('admin/structure/ds/list/search', $edit, t('Save configuration'));
|
85
|
$this->drupalGet('search/content/title1');
|
86
|
$this->assertText(t('Advanced search'), 'Advanced search found');
|
87
|
|
88
|
// Search on user.
|
89
|
// Configure user. We'll just do default.
|
90
|
$layout = array(
|
91
|
'additional_settings[layout]' => 'ds_2col_stacked',
|
92
|
);
|
93
|
$assert = array(
|
94
|
'regions' => array(
|
95
|
'header' => '<td colspan="8">' . t('Header') . '</td>',
|
96
|
'left' => '<td colspan="8">' . t('Left') . '</td>',
|
97
|
'right' => '<td colspan="8">' . t('Right') . '</td>',
|
98
|
'footer' => '<td colspan="8">' . t('Footer') . '</td>',
|
99
|
),
|
100
|
);
|
101
|
$this->dsSelectLayout($layout, $assert, 'admin/config/people/accounts/display');
|
102
|
$fields = array(
|
103
|
'fields[name][region]' => 'left',
|
104
|
'fields[summary][region]' => 'right',
|
105
|
);
|
106
|
$this->dsConfigureUI($fields, 'admin/config/people/accounts/display');
|
107
|
|
108
|
$this->drupalGet('search/user/' . $this->admin_user->name);
|
109
|
$this->assertRaw('view-mode-search_result', 'Search view mode found');
|
110
|
$this->assertRaw('group-left', 'Search template found');
|
111
|
$this->assertRaw('group-right', 'Search template found');
|
112
|
|
113
|
// Test the group by settings.
|
114
|
$article = array(
|
115
|
'title' => 'group article 1',
|
116
|
'type' => 'article',
|
117
|
'promote' => 1,
|
118
|
);
|
119
|
$this->drupalCreateNode($article);
|
120
|
|
121
|
$page = array(
|
122
|
'title' => 'group page 1',
|
123
|
'type' => 'page',
|
124
|
'promote' => 1,
|
125
|
);
|
126
|
$this->drupalCreateNode($page);
|
127
|
$this->cronRun();
|
128
|
|
129
|
$edit = array(
|
130
|
'ds_search_group_by_type' => '1'
|
131
|
);
|
132
|
$this->drupalPost('admin/structure/ds/list/search', $edit, t('Save configuration'));
|
133
|
|
134
|
// Let's search.
|
135
|
$this->drupalGet('search/content/group');
|
136
|
$this->assertRaw('Results for article');
|
137
|
$this->assertRaw('Results for basic page');
|
138
|
|
139
|
$edit = array(
|
140
|
'ds_search_group_by_type_settings[article][label]' => 'Article results',
|
141
|
);
|
142
|
$this->drupalPost('admin/structure/ds/list/search', $edit, t('Save configuration'));
|
143
|
$this->drupalGet('search/content/group');
|
144
|
$this->assertNoRaw('Results for article');
|
145
|
$this->assertRaw('Article results');
|
146
|
$this->assertRaw('Results for basic page');
|
147
|
|
148
|
$edit = array(
|
149
|
'ds_search_group_by_type_settings[page][status]' => FALSE,
|
150
|
'ds_search_group_by_type_settings[article][label]' => '',
|
151
|
);
|
152
|
$this->drupalPost('admin/structure/ds/list/search', $edit, t('Save configuration'));
|
153
|
$this->drupalGet('search/content/group');
|
154
|
$this->assertNoRaw('Article results');
|
155
|
$this->assertNoRaw('Results for basic page');
|
156
|
$this->assertRaw('Other');
|
157
|
}
|
158
|
}
|