1
|
|
|
<?php
|
2
|
|
|
/**
|
3
|
|
|
* Function area: Table
|
4
|
|
|
* Subfunction area: Index
|
5
|
|
|
* @author Augmentum SpikeSource Team
|
6
|
|
|
* @copyright 2005 by Augmentum, Inc.
|
7
|
|
|
*/
|
8
|
|
|
|
9
|
|
|
// Import the precondition class.
|
10
|
|
|
if(is_dir('../Public'))
|
11
|
|
|
{
|
12
|
|
|
require_once('../Public/SetPrecondition.php');
|
13
|
|
|
}
|
14
|
|
|
|
15
|
|
|
|
16
|
|
|
/**
|
17
|
|
|
* A test case suite for testing INDEX feature in phpPgAdmin, including cases
|
18
|
|
|
* for creating, clustering, reindexing and dropping indexes.
|
19
|
|
|
*/
|
20
|
|
|
class IndexesTest extends PreconditionSet{
|
21
|
|
|
|
22
|
|
|
/**
|
23
|
|
|
* Set up the preconditon.
|
24
|
|
|
*/
|
25
|
|
|
function setUp()
|
26
|
|
|
{
|
27
|
|
|
global $webUrl;
|
28
|
|
|
global $SUPER_USER_NAME;
|
29
|
|
|
global $SUPER_USER_NAME;
|
30
|
|
|
|
31
|
|
|
$this->login($SUPER_USER_NAME, $SUPER_USER_NAME,
|
32
|
|
|
"$webUrl/login.php");
|
33
|
|
|
|
34
|
|
|
return TRUE;
|
35
|
|
|
}
|
36
|
|
|
|
37
|
|
|
/**
|
38
|
|
|
* Clean up all the result.
|
39
|
|
|
*/
|
40
|
|
|
function tearDown(){
|
41
|
|
|
$this->logout();
|
42
|
|
|
|
43
|
|
|
return TRUE;
|
44
|
|
|
}
|
45
|
|
|
|
46
|
|
|
/**
|
47
|
|
|
* TestCaseID: TCI01
|
48
|
|
|
* Test creating indexes in a table
|
49
|
|
|
*/
|
50
|
|
|
function testCreateIndex(){
|
51
|
|
|
global $webUrl;
|
52
|
|
|
global $lang, $SERVER, $DATABASE;
|
53
|
|
|
|
54
|
|
|
// Go to the Indexes page
|
55
|
|
|
$this->assertTrue($this->get("$webUrl/indexes.php", array(
|
56
|
|
|
'server' => $SERVER,
|
57
|
|
|
'action' => 'create_index',
|
58
|
|
|
'database' => $DATABASE,
|
59
|
|
|
'schema' => 'public',
|
60
|
|
|
'table' => 'student'))
|
61
|
|
|
);
|
62
|
|
|
|
63
|
|
|
// Set properties for the new index
|
64
|
|
|
$this->assertTrue($this->setField('formIndexName', 'stu_name_idx'));
|
65
|
|
|
$this->assertTrue($this->setField('TableColumnList', array('name')));
|
66
|
|
|
$this->assertTrue($this->setField('IndexColumnList[]', 'name'));
|
67
|
|
|
$this->assertTrue($this->setField('formIndexType', 'BTREE'));
|
68
|
|
|
$this->assertTrue($this->setField('formUnique', FALSE));
|
69
|
|
|
$this->assertTrue($this->setField('formSpc', 'pg_default'));
|
70
|
|
|
|
71
|
|
|
$this->assertTrue($this->clickSubmit($lang['strcreate']));
|
72
|
|
|
|
73
|
|
|
// Verify if the index is created correctly.
|
74
|
|
|
$this->assertTrue($this->assertWantedText($lang['strindexcreated']));
|
75
|
|
|
|
76
|
|
|
return TRUE;
|
77
|
|
|
}
|
78
|
|
|
|
79
|
|
|
|
80
|
|
|
/**
|
81
|
|
|
* TestCaseID: TCI02
|
82
|
|
|
* Cancel creating index
|
83
|
|
|
*/
|
84
|
|
|
function testCancelCreateIndex(){
|
85
|
|
|
global $webUrl;
|
86
|
|
|
global $lang, $SERVER, $DATABASE;
|
87
|
|
|
|
88
|
|
|
// Go to the Indexes page
|
89
|
|
|
$this->assertTrue($this->get("$webUrl/indexes.php", array(
|
90
|
|
|
'server' => $SERVER,
|
91
|
|
|
'action' => 'create_index',
|
92
|
|
|
'database' => $DATABASE,
|
93
|
|
|
'schema' => 'public',
|
94
|
|
|
'table' => 'student'))
|
95
|
|
|
);
|
96
|
|
|
|
97
|
|
|
// Set properties for the new index
|
98
|
|
|
$this->assertTrue($this->setField('formIndexName', 'stu_name_idx'));
|
99
|
|
|
$this->assertTrue($this->setField('TableColumnList', array('name')));
|
100
|
|
|
$this->assertTrue($this->setField('IndexColumnList[]', 'name'));
|
101
|
|
|
$this->assertTrue($this->setField('formIndexType', 'BTREE'));
|
102
|
|
|
$this->assertTrue($this->setField('formUnique', TRUE));
|
103
|
|
|
$this->assertTrue($this->setField('formSpc', 'pg_default'));
|
104
|
|
|
|
105
|
|
|
$this->assertTrue($this->clickSubmit($lang['strcancel']));
|
106
|
|
|
|
107
|
|
|
return TRUE;
|
108
|
|
|
}
|
109
|
|
|
|
110
|
|
|
/**
|
111
|
|
|
* TestCaseID: TRI01
|
112
|
|
|
* Test reindexing an index in a table
|
113
|
|
|
*/
|
114
|
|
|
function testReindex()
|
115
|
|
|
{
|
116
|
|
|
global $webUrl;
|
117
|
|
|
global $lang, $SERVER, $DATABASE;
|
118
|
|
|
|
119
|
|
|
// Go to the Indexes page
|
120
|
|
|
$this->assertTrue($this->get("$webUrl/indexes.php", array(
|
121
|
|
|
'server' => $SERVER,
|
122
|
|
|
'action' => 'reindex',
|
123
|
|
|
'database' => $DATABASE,
|
124
|
|
|
'schema' => 'public',
|
125
|
|
|
'table' => 'student',
|
126
|
|
|
'index' => 'stu_name_idx'))
|
127
|
|
|
);
|
128
|
|
|
|
129
|
|
|
// Verify if the index is reindexed correctly.
|
130
|
|
|
$this->assertTrue($this->assertWantedText($lang['strreindexgood']));
|
131
|
|
|
|
132
|
|
|
return TRUE;
|
133
|
|
|
}
|
134
|
|
|
|
135
|
|
|
|
136
|
|
|
/**
|
137
|
|
|
* TestCaseID: TCP01
|
138
|
|
|
* Test clustering and analyzing the primary key in a table
|
139
|
|
|
*/
|
140
|
|
|
function testClusterPrimaryKeyWithAnalyze()
|
141
|
|
|
{
|
142
|
|
|
global $webUrl;
|
143
|
|
|
global $lang, $SERVER, $DATABASE;
|
144
|
|
|
|
145
|
|
|
$this->assertTrue($this->get("$webUrl/indexes.php", array(
|
146
|
|
|
'server' => $SERVER,
|
147
|
|
|
'action' => 'confirm_cluster_index',
|
148
|
|
|
'database' => $DATABASE,
|
149
|
|
|
'schema' => 'public',
|
150
|
|
|
'table' => 'student',
|
151
|
|
|
'index' => 'student_pkey'))
|
152
|
|
|
);
|
153
|
|
|
$this->assertTrue($this->setField('analyze', TRUE));
|
154
|
|
|
$this->assertTrue($this->clickSubmit($lang['strcluster']));
|
155
|
|
|
// Verify if the key is clustered correctly.
|
156
|
|
|
$this->assertTrue($this->assertWantedText($lang['strclusteredgood']));
|
157
|
|
|
$this->assertTrue($this->assertWantedText($lang['stranalyzegood']));
|
158
|
|
|
|
159
|
|
|
return TRUE;
|
160
|
|
|
}
|
161
|
|
|
|
162
|
|
|
|
163
|
|
|
/**
|
164
|
|
|
* TestCaseID: TCP02
|
165
|
|
|
* Test clustering the primary key without analyzing in a table
|
166
|
|
|
*/
|
167
|
|
|
function testClusterPrimaryKeyWithoutAnalyze()
|
168
|
|
|
{
|
169
|
|
|
global $webUrl;
|
170
|
|
|
global $lang, $SERVER, $DATABASE;
|
171
|
|
|
|
172
|
|
|
$this->assertTrue($this->get("$webUrl/indexes.php", array(
|
173
|
|
|
'server' => $SERVER,
|
174
|
|
|
'action' => 'confirm_cluster_index',
|
175
|
|
|
'database' => $DATABASE,
|
176
|
|
|
'schema' => 'public',
|
177
|
|
|
'table' => 'student',
|
178
|
|
|
'index' => 'student_pkey'))
|
179
|
|
|
);
|
180
|
|
|
$this->assertTrue($this->setField('analyze', FALSE));
|
181
|
|
|
$this->assertTrue($this->clickSubmit($lang['strcluster']));
|
182
|
|
|
// Verify if the key is clustered correctly.
|
183
|
|
|
$this->assertTrue($this->assertWantedText($lang['strclusteredgood']));
|
184
|
|
|
|
185
|
|
|
return TRUE;
|
186
|
|
|
}
|
187
|
|
|
|
188
|
|
|
|
189
|
|
|
/**
|
190
|
|
|
* TestCaseID: TCP03
|
191
|
|
|
* Test cancelling clustering the primary key in a table
|
192
|
|
|
*/
|
193
|
|
|
function testCancelCluster()
|
194
|
|
|
{
|
195
|
|
|
global $webUrl;
|
196
|
|
|
global $lang, $SERVER, $DATABASE;
|
197
|
|
|
|
198
|
|
|
$this->assertTrue($this->get("$webUrl/indexes.php", array(
|
199
|
|
|
'server' => $SERVER,
|
200
|
|
|
'action' => 'confirm_cluster_index',
|
201
|
|
|
'database' => $DATABASE,
|
202
|
|
|
'schema' => 'public',
|
203
|
|
|
'table' => 'student',
|
204
|
|
|
'constraint' => 'student_pkey'))
|
205
|
|
|
);
|
206
|
|
|
$this->assertTrue($this->setField('analyze', TRUE));
|
207
|
|
|
$this->assertTrue($this->clickSubmit($lang['strcancel']));
|
208
|
|
|
|
209
|
|
|
return TRUE;
|
210
|
|
|
}
|
211
|
|
|
|
212
|
|
|
/**
|
213
|
|
|
* TestCaseID: TDI02
|
214
|
|
|
* Cancel dropping an index in a table
|
215
|
|
|
*/
|
216
|
|
|
function testCancelDropIndex()
|
217
|
|
|
{
|
218
|
|
|
global $webUrl;
|
219
|
|
|
global $lang, $SERVER, $DATABASE;
|
220
|
|
|
|
221
|
|
|
$this->assertTrue($this->get("$webUrl/indexes.php", array(
|
222
|
|
|
'server' => $SERVER,
|
223
|
|
|
'action' => 'confirm_drop_index',
|
224
|
|
|
'database' => $DATABASE,
|
225
|
|
|
'schema' => 'public',
|
226
|
|
|
'table' => 'student',
|
227
|
|
|
'index' => 'stu_name_idx'))
|
228
|
|
|
);
|
229
|
|
|
$this->assertField($this->setField('cascade', FALSE));
|
230
|
|
|
$this->assertTrue($this->clickSubmit($lang['strcancel']));
|
231
|
|
|
|
232
|
|
|
return TRUE;
|
233
|
|
|
}
|
234
|
|
|
|
235
|
|
|
/**
|
236
|
|
|
* TestCaseID: TDI01
|
237
|
|
|
* Test dropping an index in a table
|
238
|
|
|
*/
|
239
|
|
|
function testDropIndex()
|
240
|
|
|
{
|
241
|
|
|
global $webUrl;
|
242
|
|
|
global $lang, $SERVER, $DATABASE;
|
243
|
|
|
|
244
|
|
|
$this->assertTrue($this->get("$webUrl/indexes.php", array(
|
245
|
|
|
'server' => $SERVER,
|
246
|
|
|
'action' => 'confirm_drop_index',
|
247
|
|
|
'database' => $DATABASE,
|
248
|
|
|
'schema' => 'public',
|
249
|
|
|
'table' => 'student',
|
250
|
|
|
'index' => 'stu_name_idx'))
|
251
|
|
|
);
|
252
|
|
|
$this->assertField($this->setField('cascade', TRUE));
|
253
|
|
|
$this->assertTrue($this->clickSubmit($lang['strdrop']));
|
254
|
|
|
// Verify if the index is dropped correctly.
|
255
|
|
|
$this->assertTrue($this->assertWantedText($lang['strindexdropped']));
|
256
|
|
|
|
257
|
|
|
return TRUE;
|
258
|
|
|
}
|
259
|
|
|
}
|
260
|
|
|
|