-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTR_repStatus.php
134 lines (108 loc) · 3.64 KB
/
TR_repStatus.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
#EDITED: This file was modified to make the report function corectly.
#EDITED: To track the changes made besides the commented-out sections, follow the tag "EDITED"
class TR_repStatus extends TR_Template{
private $supportedCharts = array();
private $supportedChartTypes = array(
"google" => array( "bar", "pie", "pie3" ),
);
function getSupportedChartsArr() {
return $this->supportedCharts;
}
function getSupportedChartTypesArr() {
return $this->supportedChartTypes;
}
/**
* implementation of the abstract function of the super class
*/
function getReport( $result ) {
# check and set some parameters
# field for calculating the total number; could be set to a field that is included in the field list of the select statement or to rowcount, which will simply count number of rows
if ($this->getArgs()->get("total") == "true") {
$this->getArgs()->set("total", "Count");
}
$output = $this->renderPlainHTML( $result );
#returning the output
return $output;
}
function getReportName() {
return "Test Case Status Report";
}
/**
* Create the report header
**/
function getReportHeader() {
return $this->getStandardRunHeader();
}
function getReportFooter() {
#return "<b>Number of test cases in this run: ".$this->getTotal()."</b>";
return "";
}
function getSQL() {
$sql = new TR_SQL;
$sql->setConnector($this->getConnector());
$sql->setFrom("test_case_runs");
$sql->addField("test_case_run_status", "name", "Status");
$sql->addField("test_case_runs", "case_run_id", "Count", "count(distinct $1)");
# $sql->addJoin("Inner", "=", "test_case_runs", "case_id", "test_cases", "case_id");
$sql->addJoin("Inner", "=", "test_case_run_status", "case_run_status_id", "test_case_runs", "case_run_status_id");
$run_ids = explode(", ", $this->getRunID());
$run_counter = 0;
foreach ($run_ids as $run_id) {
if ($run_counter == 0) {
$sql->addWhere("test_case_runs", "run_id", "=", $run_id);
$sql->addWhere("test_case_runs", "iscurrent", "=", "1", "AND");#EDITED: added this line to use only current build/environment for ca case run
$run_counter ++;
}
else {
$sql->addWhere("test_case_runs", "run_id", "=", $run_id, "OR");
$sql->addWhere("test_case_runs", "iscurrent", "=", "1", "AND");#EDITED: added this line to use only current build/environment for ca case run
}
}
# $sql->addGroupSort("Group","test_case_runs", "run_id");
$sql->addGroupSort("Group","test_case_run_status", "name");
# $sql->addGroupSort("Order","test_case_run_status", "name");
#var_dump($sql->toSQL());
#exit;
return $sql->toSQL();
}
function getGoogleChartLink( &$google, $result, $type, $chart ) {
$color = new TR_Colors;
$label="";
$data="";
$href="";
$total=0;
if (!$this->getTotal()) {
$this->calcTotal( $result );
$total=$this->getTotal();
} else {
$total = $this->getTotal();
}
$google->setDataMinRange(0);
foreach ($result as $line) {
$plotData = "";
$i=0;
foreach ($line as $col_value) {
#labels and colors
if ($i==0) {
$label=$col_value;
$google->addColor($color->getColorHTML($col_value, "tcrs"));
}
#data
if ($i==1) {
$label.="(".$col_value.")";
if ($total) {
$label.= "+".round($col_value/$total*100)."%";
}
$google->addLabel($label);
$google->addLegend($label);
$google->addData($col_value);
}
$i++;
}
}
if ($type == "bar") { $google->hideLabels( true ); }
if ($type == "pie" or $type == "pie3") { $google->hideLegend( true ); }
}
}
?>