3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
22 class TestRecorder
implements ITestRecorder
{
26 function __construct( $parent ) {
27 $this->parent
= $parent;
28 $this->term
= $parent->term
;
36 function record( $test, $subtest, $result ) {
38 $this->success +
= ( $result ?
1 : 0 );
46 if ( $this->total
> 0 ) {
47 $this->reportPercentage( $this->success
, $this->total
);
49 throw new MWException( "No tests found.\n" );
53 function reportPercentage( $success, $total ) {
54 $ratio = wfPercent( 100 * $success / $total );
55 print $this->term
->color( 1 ) . "Passed $success of $total tests ($ratio)... ";
57 if ( $success == $total ) {
58 print $this->term
->color( 32 ) . "ALL TESTS PASSED!";
60 $failed = $total - $success;
61 print $this->term
->color( 31 ) . "$failed tests failed!";
64 print $this->term
->reset() . "\n";
66 return ( $success == $total );