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

ReportsTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Function area: Server
4
 * Sub function area: Reports
5
 *
6
 * @author     Augmentum SpikeSource Team 
7
 * @copyright  2005 by Augmentum, Inc.
8
 */
9
10
// Import the precondition class.
11
if(is_dir('../Public')) 
12
{
13
    require_once('../Public/SetPrecondition.php');
14
}
15
16
/**
17
 * This class is to test the report management.
18
 * It includes create/drop/edit/list/run reports.
19
 */
20
class ReportsTest extends PreconditionSet 
21
{
22
    // Declare the member variable for report name.
23
    private $_reportName = "testReport";
24
    
25
    function setUp()
26
    {
27
        global $webUrl;
28
        global $SUPER_USER_NAME;
29
        global $SUPER_USER_PASSWORD;
30
        
31
        $this->login($SUPER_USER_NAME, $SUPER_USER_PASSWORD, "$webUrl/login.php");
32
        
33
        return TRUE;
34
    }
35
    
36
    
37
    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...
38
    {
39
        $this->logout();
40
        
41
        return TRUE;
42
    }
43
   
44
   
45
    /*
46
     * TestCaseID: SCR01
47
     * Test to create report.
48
     */
49
    function testCreate() 
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...
50
    {
51
        global $webUrl;
52
        global $lang, $SERVER, $DATABASE;
53
54
        // Turn to the create report page.
55
		$this->assertTrue($this->get("$webUrl/reports.php", array('server' => $SERVER)));
56
        $this->assertTrue($this->clickLink($lang['strcreatereport']));
57
58
        // Enter information for creating a report.
59
        $this->assertTrue($this->setField('report_name', $this->_reportName));
60
        $this->assertTrue($this->setField('db_name', $DATABASE));
61
        $this->assertTrue($this->setField('descr', 'comment'));
62
        $this->assertTrue($this->setField('report_sql', 'select * from student where 1=0'));
63
64
        //Then submit and verify it.
65
        $this->assertTrue($this->clickSubmit($lang['strsave']));
66
        $this->assertWantedText($lang['strreportcreated']);
67
        $this->assertWantedText($this->_reportName);
68
69
        return TRUE;
70
    }
71
72
73
    /*
74
     * TestCaseID: SRR01
75
     * Test to run existing report.
76
     */
77
    function testRun() 
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...
78
    {
79
        global $webUrl;
80
        global $lang, $SERVER;
81
82
        // Run the existing report and verify it.
83
		$this->assertTrue($this->get("$webUrl/reports.php", array('server' => $SERVER)));
84
		$this->assertTrue($this->clickLink($lang['strexecute']));
85
        $this->assertWantedText($lang['strnodata']);
86
87
/* XXX there's no refresh link on report results page. see sql.php
88
		$this->assertTrue($this->clickLink($lang['strrefresh']));
89
        $this->assertWantedText($lang['strnodata']);
90
 */
91
/* XXX there's no expand-collapse link on report results page. see sql.php
92
        $this->assertTrue($this->clickLink($lang['strexpand']));
93
        $this->assertWantedText($lang['strnodata']);
94
        $this->assertWantedText($lang['strcollapse']);
95
96
        $this->assertTrue($this->clickLink($lang['strcollapse']));
97
        $this->assertWantedText($lang['strnodata']);
98
		$this->assertWantedText($lang['strexpand']);
99
*/
100
101
/* XXX btw, there's a "create report" link in the report results page o_O */
102
103
        return TRUE;
104
    }
105
106
107
    /*
108
     * TestCaseID: SER01
109
     * Test to edit existing report. 
110
     */
111
    function testEdit() 
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...
112
    {
113
        global $webUrl;
114
        global $lang, $SERVER, $DATABASE;
115
116
        // Turn to the edit report page.
117
        $this->assertTrue($this->get("$webUrl/reports.php", array('server' => $SERVER)));
118
        $this->assertTrue($this->clickLink($this->_reportName));
119
        $this->assertTrue($this->clickLink($lang['stredit']));
120
121
        // Enter the information for altering the report's properties.
122
        $this->assertTrue($this->setField('report_name', $this->_reportName));
123
        $this->assertTrue($this->setField('db_name', $DATABASE));
124
        $this->assertTrue($this->setField('descr', 'comment is changed'));
125
        $this->assertTrue($this->setField('report_sql', 'select * from student where 0=1'));
126
127
        // Then submit and verify it.
128
        $this->assertTrue($this->clickSubmit($lang['strsave']));
129
        $this->assertWantedText($lang['strreportcreated']);
130
        $this->assertWantedText($this->_reportName);
131
        
132
        return TRUE;
133
    }
134
    
135
    
136
    /*
137
     * TestCaseID: SDR01
138
     * Test to drop existing report.
139
     */
140
    function testDrop() 
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...
141
    {
142
        global $webUrl;
143
        global $lang, $SERVER;
144
145
        // Turn to the drop report page.
146
        $this->assertTrue($this->get("$webUrl/reports.php", array('server' => $SERVER)));
147
        $this->assertTrue($this->clickLink($lang['strdrop']));
148
       
149
        // Confirm to drop the report and verify it.        
150
        $this->assertTrue($this->clickSubmit($lang['strdrop']));
151
        $this->assertWantedText($lang['strreportdropped']);
152
        
153
        return TRUE;
154
    }
155
}
156
?>
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...
157