Test Failed
Branch develop (db5506)
by Felipe
03:46
created

TableSpacesTest::testAlter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 0
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
1
<?php
2
/**
3
 * Function area: Server
4
 * Sub function area: TableSpaces
5
 *
6
 * @author     Augmentum SpikeSource Team 
7
 * @copyright  2005 by Augmentum, Inc.
8
 */
9
10
11
// Import the precondition class.
12
if(is_dir('../Public')) 
13
{
14
    require_once('../Public/SetPrecondition.php');
15
}
16
17
/**
18
 * This class is to test the tablespace management.
19
 * It includes create/drop/alter/list tablespaces.
20
 */
21
class TableSpacesTest extends PreconditionSet 
22
{
23
    // Declare member variables for the table space name and location.
24
    private $_tableSpaceName = 'TestTableSpace';
25
    private $_location;
26
    
27
    function setUp()
28
    {
29
        global $webUrl;
30
        global $SUPER_USER_NAME;
31
        global $SUPER_USER_PASSWORD;
32
        global $lang;
33
        
34
        $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, "$webUrl/login.php");
35
36
        return TRUE;
37
    }
38
    
39
    function tearDown()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
40
    {
41
        $this->logout();
42
        
43
        return TRUE;
44
    }
45
   
46
   
47
    /*
48
     * TestCaseID: SCT01
49
	 * Test to create tablespace.
50
	 * XXX: Your PgSQL admin user must own data/TableSpace
51
     */
52
    function testCreate() 
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
53
    {
54
        global $webUrl;
55
        global $POWER_USER_NAME;
56
        global $lang, $SERVER;
57
        $this->_location = getcwd() . '/data/TableSpace';
58
59
        // Turn to the create tablespace page.
60
        $this->assertTrue($this->get("$webUrl/tablespaces.php", array('server' => $SERVER)));
61
        $this->assertTrue($this->clickLink($lang['strcreatetablespace']));
62
       
63
        // Enter information for creating a tablespace.
64
        $this->assertTrue($this->setField('formSpcname', $this->_tableSpaceName));
65
        $this->assertTrue($this->setField('formOwner', $POWER_USER_NAME));
66
        $this->assertTrue($this->setField('formLoc', $this->_location));
67
       
68
        // Then submit and verify it.
69
		$this->assertTrue($this->clickSubmit($lang['strcreate']));
70
		$this->assertWantedText($lang['strtablespacecreated']);
71
        
72
        return TRUE;
73
    }
74
    
75
    
76
    /*
77
     * TestCaseID: SAT01
78
     * Test to alter existing tablespace's properties.
79
     */
80
    function testAlter() 
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
81
    {
82
        global $webUrl;
83
        global $NORMAL_USER_NAME;
84
        global $lang, $SERVER;
85
        
86
        // Turn to the alter tablespace page.
87
		$this->assertTrue($this->get("$webUrl/tablespaces.php", array('server' => $SERVER)));
88
		$this->assertTrue($this->get("$webUrl/tablespaces.php", array(
89
			            'server' => $SERVER,
90
						'action' => 'edit',
91
						'tablespace' => $this->_tableSpaceName))
92
					);
93
94
        // Enter information for altering the tableSpace's properties.
95
        $this->assertTrue($this->setField('name', $this->_tableSpaceName));
96
        $this->assertTrue($this->setField('owner', $NORMAL_USER_NAME));
97
98
        // Then submit and verify it.
99
        $this->assertTrue($this->clickSubmit($lang['stralter']));
100
        $this->assertWantedText($lang['strtablespacealtered']);
101
102
        return TRUE;
103
    }
104
    
105
    /*
106
     * TestCaseID: SPT01
107
     * Test to grant privileges for tablespace.
108
     */
109
    function testGrantPrivilege() 
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
110
    {
111
        global $webUrl;
112
        global $NORMAL_USER_NAME;
113
        global $lang, $SERVER;
114
        
115
        // Turn to the privileges page.
116
        $this->assertTrue($this->get("$webUrl/privileges.php", array('server' => $SERVER)));
117
		$this->assertTrue($this->get("$webUrl/privileges.php", array(
118
			            'server' => $SERVER,
119
						'subject' => 'tablespace',
120
						'tablespace' => $this->_tableSpaceName))
121
					);
122
       
123
        // Grant with no privileges selected.
124
        $this->assertTrue($this->clickLink($lang['strgrant']));
125
        $this->assertTrue($this->setField('username[]', array($NORMAL_USER_NAME)));
126
        $this->assertTrue($this->setField('privilege[CREATE]', TRUE));
127
        $this->assertTrue($this->setField('privilege[ALL PRIVILEGES]', TRUE));
128
        $this->assertTrue($this->setField('grantoption', TRUE));
129
       
130
        // Then submit and verifiy it.
131
        $this->assertTrue($this->clickSubmit($lang['strgrant']));
132
        $this->assertWantedText($lang['strgranted']);
133
        $this->assertWantedText($NORMAL_USER_NAME);
134
        
135
        return TRUE;
136
    }
137
    
138
    /*
139
     * TestCaseID: SPT02
140
     * Test to revoke privileges for tablespace.
141
     */
142
    function testRevokePrivilege() 
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
143
    {
144
        global $webUrl;
145
        global $NORMAL_USER_NAME;
146
        global $lang, $SERVER;
147
        
148
        // Turn to the privileges page.
149
        $this->assertTrue($this->get("$webUrl/privileges.php", array('server' => $SERVER)));
150
		$this->assertTrue($this->get("$webUrl/privileges.php", array(
151
			            'server' => $SERVER,
152
						'subject' => 'tablespace',
153
						'tablespace' => $this->_tableSpaceName))
154
					);
155
       
156
        // Revoke with no users selected.
157
        $this->assertTrue($this->clickLink($lang['strrevoke']));
158
        $this->assertTrue($this->setField('username[]', array($NORMAL_USER_NAME)));
159
        $this->assertTrue($this->setField('privilege[ALL PRIVILEGES]', TRUE));
160
               
161
        // Then submit and verify it.
162
        $this->assertTrue($this->clickSubmit($lang['strrevoke']));
163
        $this->assertWantedText($lang['strgranted']);
164
        $this->assertNoUnWantedText($NORMAL_USER_NAME);
165
        
166
        return TRUE;
167
    }
168
    
169
    
170
    /*
171
     * TestCaseID: SPT03
172
     * Test to grant privilege with no privilege selected for tablespace.
173
     */
174
    function testGrantNoPrivilege() 
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
175
    {
176
        global $webUrl;
177
        global $NORMAL_USER_NAME;
178
        global $lang, $SERVER;
179
        
180
        // Turn to the privileges page.
181
        $this->assertTrue($this->get("$webUrl/privileges.php", array('server' => $SERVER)));
182
		$this->assertTrue($this->get("$webUrl/privileges.php", array(
183
			            'server' => $SERVER,
184
						'subject' => 'tablespace',
185
						'tablespace' => $this->_tableSpaceName))
186
		);
187
       
188
        // Grant whit no privilege selected.
189
        $this->assertTrue($this->clickLink($lang['strgrant']));
190
        $this->assertTrue($this->setField('username[]', array($NORMAL_USER_NAME)));
191
192
        // Then submit and verify it.
193
        $this->assertTrue($this->clickSubmit($lang['strgrant']));
194
        $this->assertWantedText($lang['strgrantbad']);
195
        
196
        return TRUE;
197
    }
198
    
199
    /*
200
     * TestCaseID: SPT04
201
     * Test to revoke privileges with no user selected for tablespace.
202
     */
203
    function testRevokeNoUser() 
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
204
    {
205
        global $webUrl;
206
        global $NORMAL_USER_NAME;
207
        global $lang, $SERVER;
208
        
209
        // Turn to the privileges page.
210
        $this->assertTrue($this->get("$webUrl/privileges.php", array('server' => $SERVER)));
211
		$this->assertTrue($this->get("$webUrl/privileges.php", array(
212
			            'server' => $SERVER,
213
						'subject' => 'tablespace',
214
						'tablespace' => $this->_tableSpaceName))
215
		);
216
       
217
        // Revoke whit no users selected.
218
        $this->assertTrue($this->clickLink($lang['strrevoke']));
219
220
        // Then submit and verify it.
221
        $this->assertTrue($this->clickSubmit($lang['strrevoke']));
222
        $this->assertWantedText($lang['strgrantbad']);
223
        
224
        return TRUE;
225
    }
226
    
227
    
228
    /*
229
     * TestCaseID: SDT01
230
     * Test to drop existing tablespace.
231
     */
232
    function testDrop() 
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
233
    {
234
        global $webUrl;
235
        global $lang, $SERVER;
236
        
237
        // Turn to the drop user page.
238
        $this->assertTrue($this->get("$webUrl/tablespaces.php", array('server' => $SERVER)));
239
		$this->assertTrue($this->get("$webUrl/tablespaces.php", array(
240
			            'server' => $SERVER,
241
						'action' => 'confirm_drop',
242
						'tablespace' => $this->_tableSpaceName))
243
		);
244
245
        // Confirm to drop the user and verify it.
246
        $this->assertTrue($this->clickSubmit($lang['strdrop']));
247
        $this->assertWantedText($lang['strtablespacedropped']);
248
        $this->assertNoUnWantedText($this->_tableSpaceName);  
249
        
250
        return TRUE;
251
    }
252
}
253
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
254