Passed
Pull Request — develop (#92)
by Felipe
06:21
created

AggregateTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 106
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 6 1
A testBrowseAggregates() 0 15 1
A setUp() 0 11 1
A testCreateAggregate() 0 23 1
A testDropAggregate() 0 22 1
1
<?php
2
 /**
3
  * Function area:       Schemas
4
  * Subfunction area:    Aggregate
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 AGGREGATE feature in phpPgAdmin, including
17
 * cases for adding, browsing and dropping aggregates.
18
 */
19
class AggregateTest 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
     * Clean up all the result. 
39
     */
40
    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...
41
    {
42
        // Logout from the system.
43
        $this->logout(); 
44
        
45
        return TRUE;
46
    }
47
48
    /**
49
     * TestCaseID: HCA01
50
     * Creates a new aggregate.
51
     */
52
    function testCreateAggregate()
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...
53
    {
54
        global $webUrl;
55
        global $lang, $SERVER, $DATABASE;
56
57
        // Turn to "sql" page.
58
		$this->assertTrue($this->get("$webUrl/database.php", array(
59
			            'server' => $SERVER,
60
						'database' => $DATABASE,
61
						'subject' => 'database',
62
						'action' => 'sql'))
63
					);
64
        // Enter the definition of the new aggregate.
65
        $this->assertTrue($this->setField('query', 'CREATE AGGREGATE ' .
66
                                          'complex_sum(sfunc1 = box_intersect, basetype = box,' .
67
                                          ' stype1 = box, initcond1 = \'(0,0)\');'));  
68
        
69
        // Click the button "Go" to create a new aggregate.
70
        $this->assertTrue($this->clickSubmit($lang['strgo']));        
71
        // Verify whether the aggregates is created correctly.
72
        $this->assertTrue($this->assertWantedText($lang['strsqlexecuted'])); 
73
74
       return TRUE;
75
    } 
76
     
77
     
78
    /**
79
     * TestCaseID: HBA01
80
     * Displays all the aggregates.
81
     */
82
    function testBrowseAggregates()
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...
83
    {
84
        global $webUrl;
85
        global $lang, $SERVER, $DATABASE;
86
        
87
        // Turn to "Aggregates" page.
88
		$this->assertTrue($this->get("$webUrl/aggregates.php", array(
89
			            'server' => $SERVER,
90
						'database' => $DATABASE,
91
						'schema' => 'public',
92
						'subject' => 'schema')
93
					));
94
95
        // Verify whether the aggregates is displayed correctly.
96
        $this->assertTrue($this->assertWantedText('complex_sum'));       
97
    }    
98
99
    /**
100
     * TestCaseID: HDA01
101
     * Drop a aggregate. 
102
     */
103
    function testDropAggregate()
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...
104
    {
105
        global $webUrl;
106
        global $lang, $SERVER, $DATABASE;
107
        
108
        // Turn to "sql" page.
109
		$this->assertTrue($this->get("$webUrl/database.php", array(
110
			            'server' => $SERVER,
111
						'database' => $DATABASE,
112
						'subject' => 'database',
113
						'action' => 'sql'))
114
					);
115
116
        $this->assertTrue($this->setField('query', 'DROP AGGREGATE' .
117
                                          ' complex_sum(box);'));  
118
119
        // Click the button "Go" to drop the aggregate.
120
        $this->assertTrue($this->clickSubmit($lang['strgo']));
121
        // Verify whether the aggregates is dropped correctly.
122
        $this->assertTrue($this->assertWantedText($lang['strsqlexecuted']));
123
        
124
        return TRUE;
125
    } 
126
}
127
?>
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...
128