Passed
Branch develop (7ff7f1)
by Felipe
10:16 queued 06:26
created

OperatorTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 126
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 126
rs 10
c 0
b 0
f 0
wmc 5
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()
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: HCO01
52
     * Create a operator.
53
     */
54
    function testCreateOperator()
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()
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()
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
?>
149