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

SchemaBasicTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 136
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 136
rs 10
c 0
b 0
f 0
wmc 5
1
<?php
2
/**
3
 * Function area     : Database.
4
 * Sub Function area : SchemaBasic.
5
 * 
6
 * @author     Augmentum SpikeSource Team
7
 * @copyright  Copyright (c) 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 Schema Basic Management of
19
 * PostgreSql implementation.
20
 */
21
class SchemaBasicTest extends PreconditionSet
22
{
23
    /**
24
     * Set up the preconditon.
25
     */
26
    function setUp()
27
    {
28
        global $webUrl;
29
        global $SUPER_USER_NAME;
30
        global $SUPER_USER_PASSWORD;
31
32
        $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD,
33
            "$webUrl/login.php");
34
35
        return TRUE;
36
    }
37
38
39
    /**
40
     * Release the relational resource.
41
     */
42
    function tearDown()
43
    {
44
        // Logout this system.
45
        $this->logout();
46
47
        return TRUE;
48
    }
49
50
51
    /**
52
     * TestCaseId: DCS001
53
     * This test is used to create one new schema for super user.
54
     */
55
    function testCreateBasSchema()
56
    {
57
        global $webUrl, $SUPER_USER_NAME;
58
        global $lang, $SERVER, $DATABASE;
59
60
		$this->assertTrue($this->get("$webUrl/database.php", array(
61
			            'server' => $SERVER,
62
						'database' => $DATABASE,
63
						'subject' => 'database'))
64
					);
65
		$this->assertTrue($this->get("$webUrl/schemas.php", array(
66
			            'server' => $SERVER,
67
						'database' => $DATABASE,
68
						'action' => 'create'))
69
					);
70
71
        $this->assertTrue($this->setField('formName', 'testSchemaName'));
72
        $this->assertTrue($this->setField('formAuth', $SUPER_USER_NAME));
73
        $this->assertTrue($this->setField('formComment',
74
                                          'Comment of test schema.'));
75
76
        $this->assertTrue($this->clickSubmit($lang['strcreate']));
77
78
        $this->assertWantedText($lang['strschemacreated']);
79
80
        return TRUE;
81
    }
82
83
    
84
    /**
85
     * TestCaseId: DAS001
86
     * This test is used to modify one existent schema for super user.
87
     */
88
    function testAlterBasSchema()
89
    {
90
        global $webUrl;
91
        global $lang, $SERVER, $DATABASE;
92
93
		$this->assertTrue($this->get("$webUrl/database.php", array(
94
			            'server' => $SERVER,
95
						'database' => $DATABASE,
96
						'subject' => 'database'))
97
		);
98
		$this->assertTrue($this->get("$webUrl/redirect.php", array(
99
			            'server' => $SERVER,
100
						'section' => 'database',
101
						'database' => $DATABASE))
102
		);
103
		$this->assertTrue($this->get("$webUrl/database.php", array(
104
			            'server' => $SERVER,
105
						'database' => $DATABASE,
106
						'subject' => 'database'))
107
		);
108
		$this->assertTrue($this->get("$webUrl/schemas.php", array(
109
			            'server' => $SERVER,
110
						'action' => 'alter',
111
						'database' => $DATABASE,
112
						'schema' => 'testSchemaName'))
113
		);
114
115
        $this->assertTrue($this->setField('comment',
116
                                          'The comment has been changed.'));
117
        $this->assertTrue($this->clickSubmit('Alter'));
118
119
        $this->assertWantedText($lang['strschemaaltered']);
120
121
        return TRUE;
122
    }
123
124
    
125
    /**
126
     * TestCaseId: DDS001
127
     * This test is used to drop one existent schema for super user.
128
     */
129
    function testDropBasSchema()
130
    {
131
        global $webUrl;
132
        global $lang, $SERVER, $DATABASE;
133
134
		$this->assertTrue($this->get("$webUrl/database.php", array(
135
			            'server' => $SERVER,
136
						'database' => $DATABASE,
137
						'subject' => 'database'))
138
		);
139
		$this->assertTrue($this->get("$webUrl/redirect.php", array(
140
			            'server' => $SERVER,
141
						'section' => 'database',
142
						'database' => $DATABASE))
143
		);
144
		$this->assertTrue($this->get("$webUrl/schemas.php", array(
145
			            'server' => $SERVER,
146
						'action' => 'drop',
147
						'database' => $DATABASE,
148
						'schema' => 'testSchemaName'))
149
		);
150
151
        $this->assertTrue($this->setField('cascade', TRUE));
152
        $this->assertTrue($this->clickSubmit($lang['strdrop']));
153
154
        $this->assertWantedText($lang['strschemadropped']);
155
        
156
        return TRUE;
157
    }
158
}
159
160
?>
161