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

OperatorTest::testCreateOperator()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 0
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
1
<?php
2
 /**
3
  * Function area:       Schemas
4
  * Subfunction area:    Operator
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 OPERATOR feature in phpPgAdmin, including
17
 * cases for creating, dropping operators and showing operator's properties.
18
 */
19
class OperatorTest extends PreconditionSet
20
{
21
    /**
22
     * Set up the precondition. 
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 $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()
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...
42
    {        
43
        // Logout from the system.
44
        $this->logout(); 
45
        
46
        return TRUE;
47
    }
48
    
49
    
50
    /**
51
     * TestCaseID: HCO01
52
     * Create a operator.
53
     */
54
    function testCreateOperator()
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...
55
    {
56
        global $webUrl;
57
        global $lang, $SERVER, $DATABASE;
58
        
59
        // Turn to "sql" page.
60
		$this->assertTrue($this->get("$webUrl/database.php", array(
61
			            'server' => $SERVER,
62
						'database' => $DATABASE,
63
						'subject' => 'database',
64
						'action' => 'sql'))
65
					);
66
        // Enter the definition of the new operator.
67
        $this->assertTrue($this->setField('query', 'CREATE OPERATOR === (' .
68
                                          'LEFTARG = box, RIGHTARG = box, PROCEDURE = box_above, ' .
69
                                          'COMMUTATOR = ==, NEGATOR = !==, RESTRICT = areasel, JOIN ' .
70
                                          '= areajoinsel);'));
71
                
72
        // Click the button "Go" to create a new operator.
73
        $this->assertTrue($this->clickSubmit($lang['strgo']));
74
        // Verify if the operator is created correctly.
75
        $this->assertTrue($this->assertWantedText($lang['strsqlexecuted']));
76
        
77
        return TRUE;
78
    } 
79
    
80
    
81
    /**
82
     * TestCaseID: HSP01
83
     * Show the properties of the specified operator.
84
     */
85
    function testShowProperty()
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...
86
    {
87
        global $webUrl;
88
        global $lang, $SERVER, $DATABASE;
89
        
90
        // Turn to "Operators" page.
91
		$this->assertTrue($this->get("$webUrl/operators.php", array(
92
		               'server' => $SERVER,
93
					   'database' => $DATABASE,
94
					   'schema' => 'public',
95
					   'subject' => 'schema'))
96
				   );
97
        // Show the properties of the operator "===".
98
        $this->assertTrue($this->clickLink('==='));
99
        // Check the properties.
100
        $this->assertTrue($this->assertWantedText('areasel')); 
101
        
102
        return TRUE;
103
    }
104
    
105
    
106
    /**
107
     * TestCaseID: HDO01
108
     * Drop the operators.
109
     */
110
    function testDropOperator()
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...
111
    {
112
        global $webUrl;
113
        global $lang, $SERVER, $DATABASE;
114
        
115
        // Turn to "Operators" page.
116
		$this->assertTrue($this->get("$webUrl/operators.php", array(
117
		               'server' => $SERVER,
118
						'database' => $DATABASE,
119
						'schema' => 'public',
120
						'subject' => 'schema'))
121
					);
122
                
123
        // Drop the first operator.        
124
        $this->assertTrue($this->clickLink($lang['strdrop']));
125
        $this->assertTrue($this->setField('cascade', TRUE));
126
        $this->assertTrue($this->clickSubmit($lang['strdrop']));
127
        // Verify whether the operator is dropped correctly.
128
        $this->assertTrue($this->assertWantedText($lang['stroperatordropped'])); 
129
                
130
        // Drop the second operator.        
131
        $this->assertTrue($this->clickLink($lang['strdrop']));
132
        $this->assertTrue($this->setField('cascade', TRUE));
133
        $this->assertTrue($this->clickSubmit($lang['strdrop']));
134
        // Verify whether the operator is dropped correctly.
135
        $this->assertTrue($this->assertWantedText($lang['stroperatordropped']));
136
                
137
        // Drop the third operator.        
138
        $this->assertTrue($this->clickLink($lang['strdrop']));
139
        $this->assertTrue($this->setField('cascade', TRUE));
140
        $this->assertTrue($this->clickSubmit($lang['strdrop']));
141
        // Verify whether the operator is dropped completely.
142
        $this->assertTrue($this->assertWantedText($lang['strnooperators']));
143
        
144
        return TRUE;
145
    } 
146
}
147
148
?>
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...
149