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()
|
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()
|
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()
|
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()
|
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()
|
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
|
|
|
?>
|
128
|
|
|
|