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

RulesTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
 /**
3
  * Function area:       Table
4
  * Subfunction area:    Rule
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 RULE feature in phpPgAdmin
18
 */
19
class RulesTest extends PreconditionSet{
20
    
21
    /**
22
     * Set up the preconditon. 
23
     */
24
    function setUp()
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...
25
    {
26
        global $webUrl;
27
        global $POWER_USER_NAME;
28
        global $POWER_USER_PASSWORD;
29
        
30
        $this->login($POWER_USER_NAME, $POWER_USER_PASSWORD, 
31
                     "$webUrl/login.php"); 
32
        
33
        return TRUE;
34
    }
35
    
36
    /**
37
     * Clean up all the result. 
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
        $this->logout(); 
41
        
42
        return TRUE;
43
    }    
44
    
45
    /**
46
     * TestCaseID: TCR01
47
     * Create a rule for a table
48
     */ 
49
    function testCreateRule()
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...
50
    {
51
        global $webUrl;
52
        global $lang, $SERVER, $DATABASE;
53
        
54
        // Go to the Rules page
55
		$this->assertTrue($this->get("$webUrl/rules.php", array(
56
			            'server' => $SERVER,
57
						'action' => 'create_rule',
58
						'database' => $DATABASE,
59
						'schema' => 'public',
60
						'table' => 'student',
61
						'subject' => 'table'))
62
					);
63
        
64
        // Set properties for the new rule    
65
        $this->assertTrue($this->setField('name', 'insert_stu_rule'));     
66
        $this->assertTrue($this->setField('event', 'INSERT')); 
67
        $this->assertTrue($this->setField('where', ''));      
68
        $this->assertTrue($this->setField('type', 'NOTHING'));         
69
        $this->assertTrue($this->clickSubmit($lang['strcreate']));
70
        
71
        // Verify if the rule is created correctly.
72
        $this->assertTrue($this->assertWantedText($lang['strrulecreated']));
73
        
74
        return TRUE;              
75
    }
76
    
77
    
78
    /**
79
     * TestCaseID: TCR02
80
     * Cancel creating a rule for a table
81
     */ 
82
    function testCancelCreateRule()
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...
83
    {
84
        global $webUrl;
85
        global $lang, $SERVER, $DATABASE;
86
        
87
        // Go to the Rules page
88
		$this->assertTrue($this->get("$webUrl/rules.php", array(
89
			            'server' => $SERVER,
90
						'action' => 'create_rule',
91
						'database' => $DATABASE,
92
						'schema' => 'public',
93
						'table' => 'student',
94
						'subject' => 'table'))
95
					);
96
        
97
        // Set properties for the new rule    
98
        $this->assertTrue($this->setField('name', 'insert_stu_rule'));     
99
        $this->assertTrue($this->setField('event', 'INSERT')); 
100
        $this->assertTrue($this->setField('where', ''));      
101
        $this->assertTrue($this->setField('instead', TRUE));                 
102
        $this->assertTrue($this->clickSubmit($lang['strcancel']));
103
        
104
        return TRUE;           
105
    }
106
    
107
    
108
    /**
109
     * TestCaseID: TDR03
110
     * Cancel the drop rule operation
111
     */ 
112
    function testCancelDropRule()
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...
113
    {
114
        global $webUrl;
115
        global $lang, $SERVER, $DATABASE;
116
        
117
        // Drop the rule
118
		$this->assertTrue($this->get("$webUrl/rules.php", array(
119
            'server' => $SERVER,
120
			'action' => 'confirm_drop',
121
			'database' => $DATABASE,
122
			'schema' => 'public',
123
			'reltype' => 'table',
124
			'table' => 'student',
125
			'subject' => 'rule',
126
			'rule' => 'insert_stu_rule'))
127
		);
128
        $this->assertTrue($this->clickSubmit($lang['strno']));
129
        
130
        return TRUE;
131
    }    
132
    
133
    /**
134
     * TestCaseID: TDR01
135
     * Drop a rule from the table
136
     */ 
137
    function testDropRule()
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...
138
    {
139
        global $webUrl;
140
        global $lang, $SERVER, $DATABASE;
141
        
142
        // Drop the rule
143
		$this->assertTrue($this->get("$webUrl/rules.php", array(
144
            'server' => $SERVER,
145
			'action' => 'confirm_drop',
146
			'database' => $DATABASE,
147
			'schema' => 'public',
148
			'reltype' => 'table',
149
			'table' => 'student',
150
			'subject' => 'rule',
151
			'rule' => 'insert_stu_rule'))
152
		);
153
        $this->assertTrue($this->clickSubmit($lang['stryes']));
154
        // Verify if the rule is dropped correctly.
155
        $this->assertTrue($this->assertWantedText($lang['strruledropped']));
156
        
157
        return TRUE; 
158
    }
159
    
160
    
161
    /**
162
     * TestCaseID: TDR02
163
     * Drop a rule from the table witch CASCADE checked
164
     */ 
165
    function testDropRuleWithCascade()
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...
166
    {
167
        global $webUrl;
168
        global $lang, $SERVER, $DATABASE;
169
        global $POWER_USER_NAME;
170
        global $POWER_USER_PASSWORD;
171
        
172
        // Go to the Rules page
173
		$this->assertTrue($this->get("$webUrl/rules.php", array(
174
			            'server' => $SERVER,
175
						'action' => 'create_rule',
176
						'database' => $DATABASE,
177
						'schema' => 'public',
178
						'table' => 'student',
179
						'subject' => 'table'))
180
					);
181
        
182
        // Set properties for the new rule    
183
        $this->assertTrue($this->setField('name', 'insert_stu_rule'));     
184
        $this->assertTrue($this->setField('event', 'INSERT')); 
185
        $this->assertTrue($this->setField('where', ''));      
186
        $this->assertTrue($this->setField('type', 'SOMETHING'));         
187
        $this->assertTrue($this->clickSubmit($lang['strcreate']));
188
        
189
        // Verify if the rule is created correctly.
190
        $this->assertTrue($this->assertWantedText($lang['strrulecreated']));  
191
        
192
        $this->logout();
193
        $this->login($POWER_USER_NAME, $POWER_USER_PASSWORD, 
194
                     "$webUrl/login.php");
195
        
196
        // Drop the rule
197
		$this->assertTrue($this->get("$webUrl/rules.php", array(
198
            'server' => $SERVER,
199
			'action' => 'confirm_drop',
200
			'database' => $DATABASE,
201
			'schema' => 'public',
202
			'reltype' => 'table',
203
			'table' => 'student',
204
			'subject' => 'rule',
205
			'rule' => 'insert_stu_rule'))
206
		);
207
        $this->assertTrue($this->setField('cascade', TRUE)); 
208
        $this->assertTrue($this->clickSubmit($lang['stryes']));
209
        // Verify if the rule is dropped correctly.
210
        $this->assertTrue($this->assertWantedText($lang['strruledropped']));
211
        
212
        return TRUE; 
213
    }                        
214
}
215
?>
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...
216