2 ////////////////////////////////////////////////////////////////////////////////
4 // File: TestcasePerVersion.php
6 // Description: Produce a report of the testcases per version
7 // Author: Andrew@ClearSCM.com
8 // Created: Mon Apr 28 15:20:06 MST 2008
12 // (c) Copyright 2008, General Dynamics, all rights reserved.
14 // All rights reserved except as subject to DFARS 252.227-7014 of contract
15 // number CP02H8901N issued under prime contract N00039-04-C-2009.
17 // Warning: This document contains technical data whose export is restricted
18 // by the Arms Export Control Act (Title 22, U.S.C., Sec 2751, et seq.) or the
19 // Export Administration Act of 1979, as amended, Title, 50, U.S.C., App. 2401
20 // et seq. Violations of these export laws are subject to severe criminal
21 // penalties. Disseminate in accordance with provisions of DoD Directive
24 ////////////////////////////////////////////////////////////////////////////////
25 $script = basename ($_SERVER["PHP_SELF"]);
27 include_once "$_SERVER[DOCUMENT_ROOT]/php/Utils.php";
28 include_once "$_SERVER[DOCUMENT_ROOT]/php/RantestDB.php";
30 $version = $_REQUEST["version"];
31 $user = $_REQUEST["user"];
33 $action = (empty ($_REQUEST["action"])) ? "Report" : $_REQUEST["action"];
34 $type = (empty ($_REQUEST["type"])) ? "All" : $_REQUEST["type"];
35 $sortBy = (empty ($_REQUEST["sortBy"])) ? "Start" : $_REQUEST["sortBy"];
36 $direction = (empty ($_REQUEST["direction"])) ? "descending" : $_REQUEST["direction"];
38 function getData ($version) {
41 $data = getTestcaseVersions ($version);
44 if ($sortBy == "Testcase") {
45 uasort ($data, "sortTestcase");
46 } elseif ($sortBy == "Unit") {
47 uasort ($data, "sortUnit");
48 } elseif ($sortBy == "Type") {
49 uasort ($data, "sortType");
50 } elseif ($sortBy == "Status") {
51 uasort ($data, "sortStatus");
52 } elseif ($sortBy == "Duration") {
53 uasort ($data, "sortDuration");
55 uasort ($data, "sortStart");
61 function createHeader () {
65 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
66 "http://www.w3.org/TR/html4/strict.dtd">
69 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
70 <link rel="stylesheet" type="text/css" media="screen" href="/css/Testing.css">
71 <link rel="stylesheet" type="text/css" media="screen" href="/css/Tables.css">
72 <title>Testcases for $versionFor</title>
80 <h1 align="center">Testcases for $versionFor</h1>
86 function createPage ($version, $forEmail = false, $message = "") {
87 global $webdir, $direction, $sortBy, $script;
89 $data = getData ($version);
92 $direction = ($direction == "ascending") ? "descending" : "ascending";
94 $urlParms = "$script?version=$version&action=$action&direction=$direction&sortBy";
97 if ($sortBy == "Testcase") {
98 $testcaseDirection = ($direction == "ascending")
99 ? "<img src=/images/down.png border=0>"
100 : "<img src=/images/up.png border=0>";
101 } elseif ($sortBy == "Unit") {
102 $unitDirection = ($direction == "ascending")
103 ? "<img src=/images/down.png border=0>"
104 : "<img src=/images/up.png border=0>";
105 } elseif ($sortBy == "Type") {
106 $typeDirection = ($direction == "ascending")
107 ? "<img src=/images/down.png border=0>"
108 : "<img src=/images/up.png border=0>";
109 } elseif ($sortBy == "Status") {
110 $statusDirection = ($direction == "ascending")
111 ? "<img src=/images/down.png border=0>"
112 : "<img src=/images/up.png border=0>";
113 } elseif ($sortBy == "Duration") {
114 $durationDirection = ($direction == "ascending")
115 ? "<img src=/images/down.png border=0>"
116 : "<img src=/images/up.png border=0>";
118 $startDirection = ($direction == "ascending")
119 ? "<img src=/images/down.png border=0>"
120 : "<img src=/images/up.png border=0>";
123 if (isset ($message)) {
124 $page .= "<div align=\"center\">$message</div>";
129 <table align="center" width="90%">
136 <th class=clear align="left" colspan="2"><a href="$script?action=Export&version=$version"><input type="submit" value="Export to CSV"></a></th>
137 <th class=clear align="right" colspan="8"><form action="$script?action=Mail&version=$version" method="post">
140 $page .= emailUsersDropdown ();
142 <input type="submit" value="Send"></form>
150 <th class=left>#</th>
151 <th><a href="$urlParms=Testcase">Testcase $testcaseDirection</a></th>
152 <th><a href="$urlParms=Start">Start Date/Time $startDirection</a></th>
153 <th><a href="$urlParms=Unit">Unit $unitDirection</a></th>
154 <th><a href="$urlParms=Type">Type $typeDirection</a></th>
155 <th><a href="$urlParms=Status">Status $statusDirection</a></th>
156 <th class=right><a href="$urlParms=Duration">Duration $durationDirection</a></th>
162 foreach ($data as $line) {
164 $row_color = setRowColor ($line["Status"]);
165 $line["Status"] = colorResult ($line["Status"]);
166 $duration = FormatDuration ($line["Duration"]);
170 <td align="center">$row_nbr</td>
171 <td><a href="rantest.php?testName=$line[Testcase]&runid=$line[_runid]&start=$line[Start]">$line[Testcase]</a></td>
172 <td align="center">$line[Start]</td>
173 <td align="center">$line[Unit]</td>
174 <td align="center">$line[Type]</td>
175 <td align="center">$line[Status]</td>
176 <td align="right">$duration</td>
189 function exportTestVersionsCSV ($version) {
190 if (isset ($version)) {
191 $title = "Testcases for $version";
192 $filename = "Testcases." . $version . ".csv";
194 $title = "Testcases for All Versions";
195 $filename = "Testcases for All Versionss.csv";
198 header ("Content-Type: application/octect-stream");
199 header ("Content-Disposition: attachment; filename=\"$filename\"");
201 print exportCSV (getData ($version), $title);
204 } // exportTestVersionsCSV
206 function setVersion () {
209 return (isset ($version)) ? $version : "All Versions";
212 function displayReport ($version, $message = "") {
213 print createHeader ();
214 print createPage ($version, false, $message);
219 function mailTestVersionsReport ($version, $pnbr, $username) {
220 if (isset ($version)) {
221 $subject = "Testcases for $version";
222 $filename = "Testcases." . $version . ".csv";
224 $subject = "Test Versions for All Tests";
225 $filename = "Test Versions for All Tests.csv";
228 $body = createPage ($version, true);
229 $attachment = exportCSV (getData ($version, true), $subject);
231 return mailReport ($pnbr, $username, $subject, $body, $filename, $attachment);
232 } // mailTestVersionsReport
236 $versionFor = setVersion ();
240 exportTestVersionsCSV ($version);
244 list ($pnbr, $username) = explode (":", $user);
245 displayReport ($version, mailTestVersionsReport ($version, $pnbr, $username));
249 displayReport ($version);