1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Function area: Common manipulation |
4
|
|
|
* Sub function area: Export |
5
|
|
|
* |
6
|
|
|
* @author Augmentum SpikeSource Team |
7
|
|
|
* @copyright 2005 by Augmentum, Inc. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
// Import the precondition class. |
11
|
|
|
if(is_dir('../Public')) |
12
|
|
|
{ |
13
|
|
|
require_once('../Public/SetPrecondition.php'); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* This class is to test the export function. |
18
|
|
|
* It includes server/database/table/view's export function. |
19
|
|
|
*/ |
20
|
|
|
class ExportTest extends PreconditionSet |
21
|
|
|
{ |
22
|
|
|
function setUp() |
23
|
|
|
{ |
24
|
|
|
global $webUrl; |
25
|
|
|
global $SUPER_USER_NAME; |
26
|
|
|
global $SUPER_USER_PASSWORD; |
27
|
|
|
|
28
|
|
|
$this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, "$webUrl/login.php"); |
29
|
|
|
|
30
|
|
|
return TRUE; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
function tearDown() |
35
|
|
|
{ |
36
|
|
|
$this->logout(); |
37
|
|
|
|
38
|
|
|
return TRUE; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/* |
43
|
|
|
* TestCaseID: CED01 |
44
|
|
|
* Test to export server data with "COPY" format. |
45
|
|
|
*/ |
46
|
|
|
function testServerDataCopyShow() |
47
|
|
|
{ |
48
|
|
|
global $webUrl, $lang, $SERVER, $DATABASE; |
49
|
|
|
|
50
|
|
|
// Turn to the export data page. |
51
|
|
|
$this->assertTrue($this->get("$webUrl/all_db.php", array( |
52
|
|
|
'action' => 'export', |
53
|
|
|
'server' => $SERVER)) |
54
|
|
|
); |
55
|
|
|
|
56
|
|
|
// Enter information for exporting the data. |
57
|
|
|
$this->assertTrue($this->setField('what', 'dataonly')); |
58
|
|
|
$this->assertTrue($this->setField('d_format', 'COPY')); |
59
|
|
|
$this->assertTrue($this->setField('output', 'show')); |
60
|
|
|
|
61
|
|
|
//Then submit and verify it. |
62
|
|
|
$this->assertTrue($this->clickSubmit($lang['strexport'])); |
63
|
|
|
$this->assertWantedText("connect $DATABASE"); |
64
|
|
|
|
65
|
|
|
return TRUE; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
/* |
70
|
|
|
* TestCaseID: CED02 |
71
|
|
|
* Test to export server structure with "SQL" format. |
72
|
|
|
*/ |
73
|
|
|
function testServerStructureSQLDownload() |
74
|
|
|
{ |
75
|
|
|
global $webUrl, $lang, $SERVER, $DATABASE; |
76
|
|
|
|
77
|
|
|
// Turn to the export data page. |
78
|
|
|
$this->assertTrue($this->get("$webUrl/all_db.php", array( |
79
|
|
|
'action' => 'export', |
80
|
|
|
'server' => $SERVER)) |
81
|
|
|
); |
82
|
|
|
|
83
|
|
|
// Enter information for exporting the data. |
84
|
|
|
$this->assertTrue($this->setField('what', 'structureonly')); |
85
|
|
|
$this->assertTrue($this->setField('d_format', 'SQL')); |
86
|
|
|
$this->assertTrue($this->setField('output', 'download')); |
87
|
|
|
|
88
|
|
|
//Then submit and verify it. |
89
|
|
|
$this->assertTrue($this->clickSubmit($lang['strexport'])); |
90
|
|
|
$this->assertWantedText("connect $DATABASE"); |
91
|
|
|
|
92
|
|
|
return TRUE; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/* |
96
|
|
|
* TestCaseID: CED03 |
97
|
|
|
* Test to export database data with "SQL" format. |
98
|
|
|
*/ |
99
|
|
|
function testDatabaseDataSQLShow() |
100
|
|
|
{ |
101
|
|
|
global $webUrl, $lang, $SERVER, $DATABASE; |
102
|
|
|
|
103
|
|
|
// Turn to the export data page. |
104
|
|
|
$this->assertTrue($this->get("$webUrl/database.php", array( |
105
|
|
|
'server' => $SERVER, |
106
|
|
|
'database' => $DATABASE, |
107
|
|
|
'subject' => 'database', |
108
|
|
|
'action' => 'export')) |
109
|
|
|
); |
110
|
|
|
|
111
|
|
|
// Enter information for exporting the data. |
112
|
|
|
$this->assertTrue($this->setField('what', 'dataonly')); |
113
|
|
|
$this->assertTrue($this->setField('d_format', 'SQL')); |
114
|
|
|
$this->assertTrue($this->setField('output', 'show')); |
115
|
|
|
|
116
|
|
|
//Then submit and verify it. |
117
|
|
|
$this->assertTrue($this->clickSubmit($lang['strexport'])); |
118
|
|
|
$this->assertWantedText('Data for Name: student'); |
119
|
|
|
|
120
|
|
|
return TRUE; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
|
124
|
|
|
/* |
125
|
|
|
* TestCaseID: CED04 |
126
|
|
|
* Test to export database structure with "COPY" format. |
127
|
|
|
*/ |
128
|
|
|
function testDatabaseStructureCOPYDownload() |
129
|
|
|
{ |
130
|
|
|
global $webUrl, $lang, $SERVER, $DATABASE; |
131
|
|
|
|
132
|
|
|
// Turn to the export data page. |
133
|
|
|
$this->assertTrue($this->get("$webUrl/database.php", array( |
134
|
|
|
'server' => $SERVER, |
135
|
|
|
'database' => $DATABASE, |
136
|
|
|
'subject' => 'database', |
137
|
|
|
'action' => 'export')) |
138
|
|
|
); |
139
|
|
|
|
140
|
|
|
// Enter information for exporting the data. |
141
|
|
|
$this->assertTrue($this->setField('what', 'structureonly')); |
142
|
|
|
$this->assertTrue($this->setField('d_format', 'COPY')); |
143
|
|
|
$this->assertTrue($this->setField('output', 'download')); |
144
|
|
|
|
145
|
|
|
//Then submit and verify it. |
146
|
|
|
$this->assertTrue($this->clickSubmit($lang['strexport'])); |
147
|
|
|
$this->assertWantedText('CREATE TABLE student'); |
148
|
|
|
|
149
|
|
|
return TRUE; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/* |
153
|
|
|
* TestCaseID: CED05 |
154
|
|
|
* Test to export table data with "XML" format. |
155
|
|
|
* |
156
|
|
|
* This test case need insert one row data firstly. |
157
|
|
|
* And the data will be removed in the end of the test case. |
158
|
|
|
*/ |
159
|
|
|
function testTableDataShow() |
160
|
|
|
{ |
161
|
|
|
global $webUrl, $lang, $SERVER, $DATABASE; |
162
|
|
|
|
163
|
|
|
// Turn to the "Insert row" interface. |
164
|
|
|
$this->assertTrue($this->get("$webUrl/tables.php", array( |
165
|
|
|
'server' => $SERVER, |
166
|
|
|
'action' => 'confinsertrow', |
167
|
|
|
'database' => $DATABASE, |
168
|
|
|
'schema' => 'public', |
169
|
|
|
'table' => 'student')) |
170
|
|
|
); |
171
|
|
|
// Set the value of the fields. |
172
|
|
|
$this->assertTrue($this->setField('values[name]', 'testname')); |
173
|
|
|
$this->assertTrue($this->setField('values[birthday]', '2005-05-31')); |
174
|
|
|
$this->assertTrue($this->setField('values[resume]', 'test resume')); |
175
|
|
|
|
176
|
|
|
// Click the "Insert" button insert a row. |
177
|
|
|
$this->assertTrue($this->clickSubmit($lang['strinsert'])); |
178
|
|
|
|
179
|
|
|
// Verify if the row insert successful. |
180
|
|
|
$this->assertTrue($this->assertWantedText($lang['strrowinserted'])); |
181
|
|
|
|
182
|
|
|
// Turn to the export data page. |
183
|
|
|
$this->assertTrue($this->get("$webUrl/tblproperties.php", array( |
184
|
|
|
'server' => $SERVER, |
185
|
|
|
'database' => $DATABASE, |
186
|
|
|
'schema' => 'public', |
187
|
|
|
'table' => 'student', |
188
|
|
|
'subject' => 'table', |
189
|
|
|
'action' => 'export')) |
190
|
|
|
); |
191
|
|
|
// Enter information for export the data. |
192
|
|
|
$this->assertTrue($this->setField('what', 'dataonly')); |
193
|
|
|
$this->assertTrue($this->setField('d_format', 'XML')); |
194
|
|
|
$this->assertTrue($this->setField('output', 'show')); |
195
|
|
|
|
196
|
|
|
// Then submit and verify it. |
197
|
|
|
$this->assertTrue($this->clickSubmit($lang['strexport'])); |
198
|
|
|
$this->assertWantedPattern("/xml version/"); |
199
|
|
|
|
200
|
|
|
|
201
|
|
|
// Turn to the export data page. |
202
|
|
|
$this->assertTrue($this->get("$webUrl/tblproperties.php", array( |
203
|
|
|
'server' => $SERVER, |
204
|
|
|
'database' => $DATABASE, |
205
|
|
|
'schema' => 'public', |
206
|
|
|
'table' => 'student', |
207
|
|
|
'subject' => 'table', |
208
|
|
|
'action' => 'export')) |
209
|
|
|
); |
210
|
|
|
|
211
|
|
|
// Enter information for exporting the data. |
212
|
|
|
$this->assertTrue($this->setField('what', 'dataonly')); |
213
|
|
|
$this->assertTrue($this->setField('d_format', 'XHTML')); |
214
|
|
|
$this->assertTrue($this->setField('output', 'show')); |
215
|
|
|
|
216
|
|
|
// Then submit and verify it. |
217
|
|
|
$this->assertTrue($this->clickSubmit($lang['strexport'])); |
218
|
|
|
$this->assertWantedPattern('/testname/'); |
219
|
|
|
|
220
|
|
|
// Empty the data in the table. |
221
|
|
|
$this->assertTrue($this->get("$webUrl/tables.php", array( |
222
|
|
|
'server' => $SERVER, |
223
|
|
|
'action' => 'confirm_empty', |
224
|
|
|
'database' => $DATABASE, |
225
|
|
|
'schema' => 'public', |
226
|
|
|
'table' => 'student')) |
227
|
|
|
); |
228
|
|
|
$this->assertTrue($this->clickSubmit($lang['strempty'])); |
229
|
|
|
|
230
|
|
|
return TRUE; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
|
234
|
|
|
/* |
235
|
|
|
* TestCaseID: CED06 |
236
|
|
|
* Test to export database structure and data with "SQL" format. |
237
|
|
|
*/ |
238
|
|
|
function testTableStructureDataSQLDownload() |
239
|
|
|
{ |
240
|
|
|
global $webUrl, $lang, $SERVER, $DATABASE; |
241
|
|
|
|
242
|
|
|
// Turn to the export data page. |
243
|
|
|
$this->assertTrue($this->get("$webUrl/tblproperties.php", array( |
244
|
|
|
'server' => $SERVER, |
245
|
|
|
'database' => $DATABASE, |
246
|
|
|
'schema' => 'public', |
247
|
|
|
'table' => 'student', |
248
|
|
|
'subject' => 'table', |
249
|
|
|
'action' => 'export')) |
250
|
|
|
); |
251
|
|
|
|
252
|
|
|
// Enter information for exporting the data. |
253
|
|
|
$this->assertTrue($this->setField('what', 'structureanddata')); |
254
|
|
|
$this->assertTrue($this->setField('sd_format', 'COPY')); |
255
|
|
|
$this->assertTrue($this->setField('output', 'download')); |
256
|
|
|
|
257
|
|
|
//Then submit and verify it. |
258
|
|
|
$this->assertTrue($this->clickSubmit($lang['strexport'])); |
259
|
|
|
$this->assertWantedText('CREATE TABLE student'); |
260
|
|
|
|
261
|
|
|
return TRUE; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/* |
265
|
|
|
* TestCaseID: CED07 |
266
|
|
|
* Test to export view structure. |
267
|
|
|
*/ |
268
|
|
|
function testViewStructureShow() |
269
|
|
|
{ |
270
|
|
|
global $webUrl, $lang, $SERVER, $DATABASE; |
271
|
|
|
|
272
|
|
|
// Turn to the export data page. |
273
|
|
|
$this->assertTrue($this->get("$webUrl/viewproperties.php", array( |
274
|
|
|
'server' => $SERVER, |
275
|
|
|
'database' => $DATABASE, |
276
|
|
|
'schema' => 'pg_catalog', |
277
|
|
|
'view' => 'pg_user', |
278
|
|
|
'subject' => 'view', |
279
|
|
|
'action' => 'export')) |
280
|
|
|
); |
281
|
|
|
|
282
|
|
|
// Enter information for exporting the data. |
283
|
|
|
$this->assertTrue($this->setField('s_clean', TRUE)); |
284
|
|
|
$this->assertTrue($this->setField('output', 'show')); |
285
|
|
|
|
286
|
|
|
//Then submit and verify it. |
287
|
|
|
$this->assertTrue($this->clickSubmit($lang['strexport'])); |
288
|
|
|
$this->assertWantedText('CREATE VIEW pg_user'); |
289
|
|
|
|
290
|
|
|
return TRUE; |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
} |
294
|
|
|
?> |
295
|
|
|
|