1
|
|
|
<?php
|
2
|
|
|
/**
|
3
|
|
|
* Function area: Schemas
|
4
|
|
|
* Subfunction area: Function
|
5
|
|
|
* @author Augmentum SpikeSource Team
|
6
|
|
|
* @copyright 2005 by Augmentum, Inc.
|
7
|
|
|
*/
|
8
|
|
|
|
9
|
|
|
// Import the precondition class.
|
10
|
|
|
if(is_dir('../Public')) {
|
11
|
|
|
require_once('../Public/SetPrecondition.php');
|
12
|
|
|
}
|
13
|
|
|
|
14
|
|
|
|
15
|
|
|
/**
|
16
|
|
|
* A test case suite for testing FUNCTION feature in phpPgAdmin, including
|
17
|
|
|
* cases for creating, altering and dropping C/Sql/Internal functions.
|
18
|
|
|
*/
|
19
|
|
|
class FunctionTest extends PreconditionSet
|
20
|
|
|
{
|
21
|
|
|
/**
|
22
|
|
|
* Set up the precondition.
|
23
|
|
|
*/
|
24
|
|
|
function setUp()
|
25
|
|
|
{
|
26
|
|
|
global $webUrl;
|
27
|
|
|
global $SUPER_USER_NAME;
|
28
|
|
|
global $SUPER_USER_PASSWORD;
|
29
|
|
|
|
30
|
|
|
// Login the system.
|
31
|
|
|
$this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD,
|
32
|
|
|
"$webUrl/login.php");
|
33
|
|
|
|
34
|
|
|
return TRUE;
|
35
|
|
|
}
|
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/**
|
39
|
|
|
* Clean up all the result.
|
40
|
|
|
*/
|
41
|
|
|
function tearDown()
|
42
|
|
|
{
|
43
|
|
|
// Logout from the system.
|
44
|
|
|
$this->logout();
|
45
|
|
|
|
46
|
|
|
return TRUE;
|
47
|
|
|
}
|
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/**
|
51
|
|
|
* TestCaseID: HCF01
|
52
|
|
|
* Create a SQL/PL function.
|
53
|
|
|
*/
|
54
|
|
|
function testCreatSqlFunction()
|
55
|
|
|
{
|
56
|
|
|
global $webUrl;
|
57
|
|
|
global $lang, $DATABASE, $SERVER;
|
58
|
|
|
|
59
|
|
|
// Turn to the "Create SQL/PL function" page.
|
60
|
|
|
$this->assertTrue($this->get("$webUrl/functions.php", array(
|
61
|
|
|
'server' => $SERVER,
|
62
|
|
|
'action' => 'create',
|
63
|
|
|
'database' => $DATABASE,
|
64
|
|
|
'schema' => 'public'))
|
65
|
|
|
);
|
66
|
|
|
|
67
|
|
|
// Enter the detail information of a SQL/PL function.
|
68
|
|
|
$this->assertTrue($this->setField('formFunction', 'sqlplfunction'));
|
69
|
|
|
$this->assertTrue($this->setField('formArguments', 'double precision[], double precision'));
|
70
|
|
|
$this->assertTrue($this->setField('formSetOf', 'SETOF'));
|
71
|
|
|
$this->assertTrue($this->setField('formReturns', 'double precision'));
|
72
|
|
|
$this->assertTrue($this->setField('formArray', '[ ]'));
|
73
|
|
|
$this->assertTrue($this->setField('formLanguage', 'sql'));
|
74
|
|
|
$this->assertTrue($this->setField('formDefinition', 'select $1'));
|
75
|
|
|
$this->assertTrue($this->setField('formProperties[0]', 'VOLATILE'));
|
76
|
|
|
$this->assertTrue($this->setField('formProperties[1]', 'RETURNS NULL ON NULL INPUT'));
|
77
|
|
|
$this->assertTrue($this->setField('formProperties[2]', 'SECURITY INVOKER'));
|
78
|
|
|
|
79
|
|
|
// Click the "Create" button to create a function.
|
80
|
|
|
$this->assertTrue($this->clickSubmit($lang['strcreate']));
|
81
|
|
|
|
82
|
|
|
// Verify whether the function is created successfully.
|
83
|
|
|
$this->assertTrue($this->assertWantedText($lang['strfunctioncreated']));
|
84
|
|
|
|
85
|
|
|
return TRUE;
|
86
|
|
|
}
|
87
|
|
|
|
88
|
|
|
/**
|
89
|
|
|
* TestCaseID: HCF02
|
90
|
|
|
* Create a internal function.
|
91
|
|
|
*/
|
92
|
|
|
function testCreateInternalFunction()
|
93
|
|
|
{
|
94
|
|
|
global $webUrl;
|
95
|
|
|
global $lang, $SERVER, $DATABASE;
|
96
|
|
|
|
97
|
|
|
// Turn to the "Create internal function" page.
|
98
|
|
|
$this->assertTrue($this->get("$webUrl/functions.php", array(
|
99
|
|
|
'server' => $SERVER,
|
100
|
|
|
'action' => 'create',
|
101
|
|
|
'language' => 'internal',
|
102
|
|
|
'database' => $DATABASE,
|
103
|
|
|
'schema' => 'public'))
|
104
|
|
|
);
|
105
|
|
|
|
106
|
|
|
// Enter the detail information of a SQL/PL function.
|
107
|
|
|
$this->assertTrue($this->setField('formFunction', 'internalfunction'));
|
108
|
|
|
$this->assertTrue($this->setField('formArguments', 'boolean'));
|
109
|
|
|
$this->assertTrue($this->setField('formSetOf', 'SETOF'));
|
110
|
|
|
$this->assertTrue($this->setField('formReturns', 'name'));
|
111
|
|
|
$this->assertTrue($this->setField('formArray', '[ ]'));
|
112
|
|
|
$this->assertTrue($this->setField('formLinkSymbol', 'current_schemas'));
|
113
|
|
|
$this->assertTrue($this->setField('formProperties[0]', 'VOLATILE'));
|
114
|
|
|
$this->assertTrue($this->setField('formProperties[1]', 'RETURNS NULL ON NULL INPUT'));
|
115
|
|
|
$this->assertTrue($this->setField('formProperties[2]', 'SECURITY INVOKER'));
|
116
|
|
|
|
117
|
|
|
// Click the "Create" button to create a function.
|
118
|
|
|
$this->assertTrue($this->clickSubmit($lang['strcreate']));
|
119
|
|
|
|
120
|
|
|
// Verify whether the function is created successfully.
|
121
|
|
|
$this->assertTrue($this->assertWantedText($lang['strfunctioncreated']));
|
122
|
|
|
|
123
|
|
|
return TRUE;
|
124
|
|
|
}
|
125
|
|
|
|
126
|
|
|
/**
|
127
|
|
|
* TestCaseID: HCF03
|
128
|
|
|
* Create a C function.
|
129
|
|
|
*/
|
130
|
|
|
function testCreateCFunction()
|
131
|
|
|
{
|
132
|
|
|
global $webUrl;
|
133
|
|
|
global $lang, $SERVER, $DATABASE;
|
134
|
|
|
|
135
|
|
|
$this->assertTrue($this->get("$webUrl/functions.php", array(
|
136
|
|
|
'server' => $SERVER,
|
137
|
|
|
'database' => $DATABASE,
|
138
|
|
|
'schema' => 'public'))
|
139
|
|
|
);
|
140
|
|
|
// Turn to the C-function create page.
|
141
|
|
|
$this->assertTrue($this->clickLink($lang['strcreatecfunction']));
|
142
|
|
|
|
143
|
|
|
// Enter the definition of the C function.
|
144
|
|
|
$this->assertTrue($this->setField('formFunction', 'cfunction'));
|
145
|
|
|
$this->assertTrue($this->setField('formArguments', 'text'));
|
146
|
|
|
$this->assertTrue($this->setField('formReturns', 'boolean'));
|
147
|
|
|
$cFunLocation = getcwd() . '/../data/CFunction/euc_jp_and_sjis';
|
148
|
|
|
$this->assertTrue($this->setField('formObjectFile', $cFunLocation));
|
149
|
|
|
$this->assertTrue($this->setField('formLinkSymbol', 'mic_to_sjis'));
|
150
|
|
|
$this->assertTrue($this->setField('formProperties[0]', 'VOLATILE'));
|
151
|
|
|
$this->assertTrue($this->setField('formProperties[1]', 'RETURNS NULL ON NULL INPUT'));
|
152
|
|
|
$this->assertTrue($this->setField('formProperties[2]', 'SECURITY DEFINER'));
|
153
|
|
|
|
154
|
|
|
// Click the "Create" button to create the C fucntion.
|
155
|
|
|
$this->assertTrue($this->clickSubmit($lang['strcreate']));
|
156
|
|
|
// Verify whether the function is created successfully.
|
157
|
|
|
$this->assertTrue($this->assertWantedText($lang['strfunctioncreated']));
|
158
|
|
|
|
159
|
|
|
return TRUE;
|
160
|
|
|
}
|
161
|
|
|
|
162
|
|
|
|
163
|
|
|
/**
|
164
|
|
|
* TestCaseID: HAF01
|
165
|
|
|
* Alter the definition of an existing function.
|
166
|
|
|
*/
|
167
|
|
|
function testAlterFunction()
|
168
|
|
|
{
|
169
|
|
|
global $webUrl;
|
170
|
|
|
global $lang, $SERVER, $DATABASE;
|
171
|
|
|
|
172
|
|
|
// Turn to the function-display page.
|
173
|
|
|
$this->assertTrue($this->get("$webUrl/functions.php", array(
|
174
|
|
|
'server' => $SERVER,
|
175
|
|
|
'database' => $DATABASE,
|
176
|
|
|
'schema' => 'public',
|
177
|
|
|
'subject' => 'schema'))
|
178
|
|
|
);
|
179
|
|
|
|
180
|
|
|
// Alter the definiton of "cfunction".
|
181
|
|
|
$this->assertTrue($this->clickLink('cfunction (text)'));
|
182
|
|
|
$this->assertTrue($this->clickLink($lang['stralter']));
|
183
|
|
|
|
184
|
|
|
// Alter the definition of the function.
|
185
|
|
|
$this->assertTrue($this->setField('formProperties[0]', 'IMMUTABLE'));
|
186
|
|
|
$this->assertTrue($this->setField('formProperties[1]', 'CALLED ON NULL INPUT'));
|
187
|
|
|
$this->assertTrue($this->setField('formProperties[2]', 'SECURITY INVOKER'));
|
188
|
|
|
|
189
|
|
|
// Click the "Create" button to alter the fucntion.
|
190
|
|
|
$this->assertTrue($this->clickSubmit($lang['stralter']));
|
191
|
|
|
// Verify whether the function is updated successfully.
|
192
|
|
|
$this->assertTrue($this->assertWantedText($lang['strfunctionupdated']));
|
193
|
|
|
|
194
|
|
|
return TRUE;
|
195
|
|
|
}
|
196
|
|
|
|
197
|
|
|
|
198
|
|
|
/**
|
199
|
|
|
* TestCaseID: HDF01
|
200
|
|
|
* Drop an existing function.
|
201
|
|
|
*/
|
202
|
|
|
function testDropFunction()
|
203
|
|
|
{
|
204
|
|
|
global $webUrl;
|
205
|
|
|
global $lang, $SERVER, $DATABASE;
|
206
|
|
|
|
207
|
|
|
// Turn to the function-display page.
|
208
|
|
|
$this->assertTrue($this->get("$webUrl/functions.php", array(
|
209
|
|
|
'server' => $SERVER,
|
210
|
|
|
'database' => $DATABASE,
|
211
|
|
|
'schema' => 'public',
|
212
|
|
|
'subject' => 'schema'))
|
213
|
|
|
);
|
214
|
|
|
|
215
|
|
|
// Drop the fucntion "sqlplfunction".
|
216
|
|
|
$this->assertTrue($this->clickLink('sqlplfunction (double precision[], double precision)'));
|
217
|
|
|
$this->assertTrue($this->clickLink($lang['strdrop']));
|
218
|
|
|
$this->assertTrue($this->setField('cascade', TRUE));
|
219
|
|
|
|
220
|
|
|
// Click the "Drop" button to dorp the function.
|
221
|
|
|
$this->assertTrue($this->clickSubmit($lang['strdrop']));
|
222
|
|
|
// Verify whether the function is dropped successfully.
|
223
|
|
|
$this->assertTrue($this->assertWantedText($lang['strfunctiondropped']));
|
224
|
|
|
|
225
|
|
|
// Drop the fucntion "cfunction".
|
226
|
|
|
$this->assertTrue($this->clickLink('cfunction (text)'));
|
227
|
|
|
$this->assertTrue($this->clickLink($lang['strdrop']));
|
228
|
|
|
$this->assertTrue($this->setField('cascade', TRUE));
|
229
|
|
|
|
230
|
|
|
// Click the "Drop" button to drop the function.
|
231
|
|
|
$this->assertTrue($this->clickSubmit($lang['strdrop']));
|
232
|
|
|
// Verify whether the function is dropped successfully.
|
233
|
|
|
$this->assertTrue($this->assertWantedText($lang['strfunctiondropped']));
|
234
|
|
|
|
235
|
|
|
// Drop the function "internalfunction".
|
236
|
|
|
$this->assertTrue($this->clickLink('internalfunction (boolean)'));
|
237
|
|
|
$this->assertTrue($this->clickLink($lang['strdrop']));
|
238
|
|
|
$this->assertTrue($this->setField('cascade', TRUE));
|
239
|
|
|
|
240
|
|
|
// Click the "Drop" button to drop the function.
|
241
|
|
|
$this->assertTrue($this->clickSubmit($lang['strdrop']));
|
242
|
|
|
// Verify whether the function is dropped successfully.
|
243
|
|
|
$this->assertTrue($this->assertWantedText($lang['strfunctiondropped']));
|
244
|
|
|
|
245
|
|
|
return TRUE;
|
246
|
|
|
}
|
247
|
|
|
}
|
248
|
|
|
?>
|
249
|
|
|
|