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

SequenceTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 121
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 121
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testResetSequence() 0 23 1
B testCreateSequence() 0 29 1
A testDropSequence() 0 20 1
A tearDown() 0 6 1
A setUp() 0 11 1
1
<?php
2
 /**
3
  * Function area:       Schemas
4
  * Subfunction area:    Sequence
5
  * @author     Augmentum SpikeSource Team 
6
  * @copyright  2005 by Augmentum, Inc.
7
  */
8
 
9
 
10
// Import the precondition class.
11
if(is_dir('../Public')) {
12
    require_once('../Public/SetPrecondition.php');
13
}
14
15
16
/**
17
 * A test case suite for testing SEQUENCE feature in phpPgAdmin, including
18
 * cases for creating, resetting and dropping sequences.
19
 */
20
class SequenceTest extends PreconditionSet
21
{
22
    /**
23
     * Set up the precondition. 
24
     */
25
    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...
26
    {
27
        global $webUrl;
28
        global $SUPER_USER_NAME;
29
        global $SUPER_USER_PASSWORD;
30
    
31
        // Login the system.
32
        $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, 
33
                     "$webUrl/login.php"); 
34
        
35
        return TRUE;          
36
    }
37
    
38
    
39
    /**
40
     * Clean up all the result. 
41
     */
42
    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...
43
    {
44
        // Logout from the system.
45
        $this->logout(); 
46
        
47
        return TRUE;
48
    }
49
    
50
    
51
    /**
52
     * TestCaseID: HCS01
53
     * Create a sequence.
54
     */
55
    function testCreateSequence()
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...
56
    {
57
        global $webUrl;
58
        global $lang, $SERVER, $DATABASE;
59
        
60
        // Turn to the "Create sequence" page.
61
		$this->assertTrue($this->get("$webUrl/sequences.php", array(
62
			            'server' => $SERVER,
63
						'action' => 'create',
64
						'database' => $DATABASE,
65
						'schema' => 'public'))
66
					);
67
                
68
        // Enter the detail information of a sequence.
69
        $this->assertTrue($this->setField('formSequenceName', 'createsequence'));    
70
        $this->assertTrue($this->setField('formIncrement', '1'));    
71
        $this->assertTrue($this->setField('formMinValue', '1000'));    
72
        $this->assertTrue($this->setField('formMaxValue', '10000'));    
73
        $this->assertTrue($this->setField('formStartValue', '1000'));    
74
        $this->assertTrue($this->setField('formCacheValue', '5'));
75
        $this->assertTrue($this->setField('formCycledValue', TRUE));
76
        
77
        // Click the "Create" button to create a sequence.
78
        $this->assertTrue($this->clickSubmit($lang['strcreate']));
79
        
80
        // Verify whether the sequence is created successfully.
81
        $this->assertTrue($this->assertWantedText($lang['strsequencecreated']));
82
83
        return TRUE;           
84
    }
85
    
86
    
87
    /**
88
     * TestCaseID: HRS01
89
     * Reset an existing sequence.
90
     */
91
    function testResetSequence()
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...
92
    {
93
        global $webUrl;
94
        global $lang, $SERVER, $DATABASE;
95
        
96
        // Turn to the sequence-display page.
97
		$this->assertTrue($this->get("$webUrl/sequences.php", array(
98
			            'server' => $SERVER,
99
						'database' => $DATABASE,
100
						'schema' => 'public',
101
						'subject' => 'schema'))
102
					);
103
        // Browse the specified sequence.
104
        $this->assertTrue($this->clickLink('createsequence')); 
105
        // Reset the sequence.
106
        $this->assertTrue($this->clickLink($lang['strreset']));
107
               
108
        // Verify whether the sequence is reset successfully.
109
        $this->assertTrue($this->assertWantedText($lang['strsequencereset']));
110
        // Display all the sequence.
111
        $this->assertTrue($this->clickLink($lang['strshowallsequences']));
112
        
113
        return TRUE;
114
    }
115
    
116
     
117
    /**
118
     * TestCaseID: HDS01
119
     * Drop a sequence.
120
     */
121
    function testDropSequence()
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...
122
    {
123
        global $webUrl;
124
        global $lang, $SERVER, $DATABASE;
125
        
126
		$this->assertTrue($this->get("$webUrl/sequences.php", array(
127
			            'server' => $SERVER,
128
						'action' => 'confirm_drop',
129
						'database' => $DATABASE,
130
						'schema' => 'public',
131
						'sequence' => 'createsequence'))
132
					);
133
134
        $this->assertTrue($this->setField('cascade', TRUE));
135
        $this->assertTrue($this->clickSubmit($lang['strdrop']));
136
137
        // Verify if the sequence dropped successful.
138
        $this->assertTrue($this->assertWantedText($lang['strsequencedropped']));
139
        
140
        return TRUE;   
141
    }
142
}
143
?>
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...
144