Passed
Push — master ( edcd19...7b8e38 )
by Felipe
05:02
created

DomainTest::testAddCheck()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
nc 1
nop 0
dl 0
loc 28
rs 8.8571
c 0
b 0
f 0
1
<?php
2
 /**
3
  * Function area:       Schemas
4
  * Subfunction area:    Domain
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 DOMAIN feature in phpPgAdmin, including
17
 * cases for creating, altering and dropping domain.
18
 */
19
class DomainTest 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
     * Cleans up all the result. 
39
     */
40
    function tearDown()
41
    {
42
        // Logout from the system.
43
        $this->logout(); 
44
        
45
        return TRUE;         
46
    }
47
    
48
    /**
49
     * TestCaseID: HCD01
50
     * Create a domain.
51
     */
52
    function testCreateDomain()
53
    {
54
        global $webUrl;
55
        global $lang, $SERVER, $DATABASE;
56
        
57
        // Turn to the "Create domain" page.
58
		$this->assertTrue($this->get("$webUrl/domains.php", array(
59
			            'server' => $SERVER,
60
						'action' => 'create',
61
						'database' => $DATABASE,
62
						'schema' => 'public'))
63
					);
64
                
65
        // Enter the detail information of the new domain.
66
        $this->assertTrue($this->setField('domname', 'spikedomain'));
67
        $this->assertTrue($this->setField('domtype', 'bigint'));
68
        $this->assertTrue($this->setField('domarray', '[ ]'));
69
        $this->assertTrue($this->setField('domnotnull', TRUE));
70
71
        // Click the "Create" button to create the domain.
72
        $this->assertTrue($this->clickSubmit($lang['strcreate']));
73
        
74
        // Verify whether the domain is created successfully.
75
        $this->assertTrue($this->assertWantedText($lang['strdomaincreated'])); 
76
        
77
        return TRUE;       
78
    } 
79
    
80
    /**
81
     * TestCaseID: HAD01
82
     * Alter the definition of a domain.
83
     */
84
    function testAlterDomain()
85
    {
86
        global $webUrl;
87
        global $lang, $SERVER, $DATABASE;
88
        
89
        // Display the domain which is to be altered.
90
		$this->assertTrue($this->get("$webUrl/domains.php", array(
91
			            'server' => $SERVER,
92
						'action' => 'properties',
93
						'database' => $DATABASE,
94
						'schema' => 'public',
95
						'domain' => 'spikedomain'))
96
					);
97
98
        $this->assertTrue($this->clickLink($lang['stralter']));
99
        $this->assertTrue($this->setField('domowner', 'tester'));    
100
101
        // Click the "Alter" button to alter the domain.
102
        $this->assertTrue($this->clickSubmit($lang['stralter']));
103
        // Verify whether the domian is altered successfully.
104
        $this->assertTrue($this->assertWantedText($lang['strdomainaltered']));    
105
106
        return TRUE;   
107
    } 
108
109
    /**
110
     * TestCaseID: HAC01
111
     * Add check to an existing domain.
112
     */
113
    function testAddCheck()
114
    {
115
        global $webUrl;
116
        global $lang, $SERVER, $DATABASE;
117
118
        // Display the domain to be be altered.
119
		$this->assertTrue($this->get("$webUrl/domains.php", array(
120
			            'server' => $SERVER,
121
						'action' => 'properties',
122
						'database' => $DATABASE,
123
						'schema' => 'public',
124
						'domain' => 'spikedomain'))
125
					);
126
127
        $this->assertTrue($this->clickLink($lang['straddcheck']));
128
129
        // Enter the check's definition.
130
        $this->assertTrue($this->setField('name', 'newcheck'));
131
        $this->assertTrue($this->setField('definition',
132
                                          'VALUE[0] > 3'));
133
134
        // Click the "Add" button add a new check.
135
        $this->assertTrue($this->clickSubmit($lang['stradd']));
136
137
        // Verify whether the new check added.
138
        $this->assertTrue($this->assertWantedText($lang['strcheckadded']));    
139
140
        return TRUE;   
141
    }    
142
143
    /**
144
     * TestCaseID: HDC01
145
     * Drops an existing constraint of a domain.
146
     */
147
    function testDropConstraint()
148
    {
149
        global $webUrl;
150
        global $lang, $SERVER, $DATABASE;
151
152
        // Turn to the domains-display page.
153
		$this->assertTrue($this->get("$webUrl/domains.php", array(
154
			            'server' => $SERVER,
155
						'database' => $DATABASE,
156
						'schema' => 'public&'))
157
					);
158
159
        // Display the specfied damain.
160
        $this->assertTrue($this->clickLink('spikedomain'));
161
162
        // Drop the constraint.
163
		$this->assertTrue($this->get("$webUrl/domains.php", array(
164
			            'server' => $SERVER,
165
						'action' => 'confirm_drop_con',
166
						'database' => $DATABASE,
167
						'schema' => 'public',
168
						'constraint' => 'newcheck',
169
						'domain' => 'spikedomain',
170
						'type' => 'c'))
171
					);
172
173
        $this->assertTrue($this->setField('cascade', TRUE));
174
175
        // Click the "Drop" button to drop the constraint.
176
        $this->assertTrue($this->clickSubmit($lang['strdrop']));
177
        // Verify whether the constraint is dropped successfully.        
178
        $this->assertTrue($this->assertWantedText($lang['strconstraintdropped']));
179
180
        return TRUE;           
181
    }
182
183
    /**
184
     * TestCaseID: HDD01
185
     * Drop an existing domain.
186
     */
187
    function testDropDomain()
188
    {
189
        global $webUrl;
190
        global $lang, $SERVER, $DATABASE;
191
192
        // Turn to the "domains" page.
193
		$this->assertTrue($this->get("$webUrl/domains.php", array(
194
			            'server' => $SERVER,
195
						'database' => $DATABASE,
196
						'schema' => 'public',
197
						'subject' => 'schema'))
198
					);
199
200
		$this->assertTrue($this->get("$webUrl/domains.php", array(
201
			            'server' => $SERVER,
202
						'action' => 'confirm_drop',
203
						'database' => $DATABASE,
204
						'schema' => 'public',
205
						'domain' => 'spikedomain'))
206
					);
207
        $this->assertTrue($this->setField('cascade', TRUE));    
208
        
209
        // Click the "Drop" button to drop the domain.
210
        $this->assertTrue($this->clickSubmit($lang['strdrop']));
211
        // Verify whether the domain is droped successfully.
212
        $this->assertTrue($this->assertWantedText($lang['strdomaindropped']));
213
        
214
        return TRUE;
215
    } 
216
} 
217
?>
218