]>
src.bluestatic.org Git - isso.git/blob - UnitTestReport.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static Unit Test Result Printer for SimpleTest
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
23 * Unit Test Result HTML Printer
28 require_once ( 'simpletest/reporter.php' );
31 * Unit Test Result Printer
33 * This is a SimpleTest result printer module that is used for all Blue Static
34 * unit testing output.
37 * @copyright Copyright ©2002 - [#]year[#], Blue Static
42 class CustomHtmlReporter
extends HtmlReporter
56 private $errors = array ();
58 private $status = true ;
60 public function paintHeader ( $test )
62 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
63 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
64 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
66 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
67 <title>Unit Test Results</title>
69 <style type="text/css">
75 font-family: "Trebuchet MS", Verdana, Helvetica, sans-serif;
80 background-color: rgb(255, 255, 255);
82 border-color: rgb(222, 222, 222);
89 background-color: rgb(222, 222, 222);
104 border-color: rgb(222, 230, 255);
105 border-style: dashed;
113 background-color: rgb(222, 230, 255);
121 color: rgb(111, 133, 255);
126 border-color: rgb(216, 255, 216);
127 border-style: dashed;
135 background-color: rgb(216, 255, 216);
143 color: rgb(76, 168, 78);
148 border-color: rgb(255, 226, 229);
149 border-style: dashed;
157 background-color: rgb(255, 226, 229);
165 color: rgb(168, 65, 63);
195 <h1>Unit Test Results: ' . $test . '</h1>' ;
198 public function paintCaseStart ( $suite )
200 $this- > suite
= $case ;
207 public function paintMethodStart ( $method )
209 $this- > method
= $method ;
210 $this- > errors
= array ();
211 $this- > status
= true ;
214 public function paintError ( $error )
216 $this- > errors
[] = $error ;
219 public function paintFail ( $message )
221 $this- > status
= false ;
222 $this- > errors
[] = $message ;
225 public function paintPass ( $message )
229 public function paintMethodEnd ( $method )
242 $this- > block
.= " \n\t\t " . '<div class="test' . ( $this- > status
? 'Success' : 'Fail' ) . ' ' . ( $this- > status
? 'green' : 'red' ) . 'Text' . ( sizeof ( $this- > errors
) > 0 ? ' negateMargin' : '' ) . '">' ;
243 $this- > block
.= " \n\t\t\t " . '<div class="test' . ( $this- > status
? 'Success' : 'Fail' ) . 'Head">' . $method . '</div>' ;
245 if ( sizeof ( $this- > errors
) > 0 )
247 $this- > block
.= " \n\t\t\t " . '<div class="textPadding">' ;
248 $this- > block
.= $this- > formatInfo ( $this- > errors
);
249 $this- > block
.= " \n\t\t\t " . '</div class="textPadding">' ;
252 $this- > block
.= " \n\t\t " . '</div>' ;
255 private function formatInfo ( $list )
258 $count = sizeof ( $list );
259 foreach ( $list AS $err )
262 $output .= " \n\t\t\t\t " . '<div class="message' . ( $count == $i ? ' messageLast' : '' ) . '">' ;
263 $output .= " \n\t\t\t\t\t " . '<div>• ' . htmlspecialchars ( $err ) . '</div>' ;
264 $output .= " \n\t\t\t\t " . '</div>' ;
270 public function paintCaseEnd ( $case )
272 $total = $this- > pass +
$this- > fail
;
273 $successPercent = round ( 100 * (( $total - $this- > fail
) / $total ), 1 );
275 $this- > html
.= '<div class="suite">' ;
276 $this- > html
.= " \n\t " . '<div class="suiteHead">' ;
277 $this- > html
.= " \n\t\t " . '<span style="float: right">' . $total . ' Tests, ' . $successPercent . '% Success' . '</span>' ;
278 $this- > html
.= " \n\t\t " . $case ;
279 $this- > html
.= " \n\t " . '</div>' ;
280 $this- > html
.= " \n\t " . '<div class="testGroup">' ;
281 $this- > html
.= $this- > block
;
282 $this- > html
.= " \n\t " . '</div>' ;
283 $this- > html
.= " \n " . '</div>' ;
284 $this- > html
.= " \n\n " . '<br />' . " \n\n " ;
287 public function paintFooter ( $test )
289 $total = $this- > getPassCount () +
$this- > getFailCount ();
292 <div>The following is a report of how each unit test performed. If any errors or exceptions were thrown, they have been recorded below. Tests have been broken down into their test suite groups. Your overall statistics are here:</div>
296 <div>Total Tests: <strong>' . $total . '</strong></div>
297 <div>Number Success: <strong class="greenText">' . $this- > getPassCount () . '</strong></div>
298 <div>Number Fail: <strong class="redText">' . $this- > getFailCount () . '</strong></div>
302 <div><em>Total Success Rate: <strong class="' . ( $this- > getPassCount () == $total ? 'green' : 'red' ) . 'Text">' . round ( 100 * ( $this- > getPassCount () / $total ), 1 ) . '%</strong></em></div>
315 /*=====================================================================*\
316 || ###################################################################
319 || ###################################################################
320 \*=====================================================================*/