blob: b3d0d01c62555a4b9fb4f493529649a282c26bcf (
plain)
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
|
<?php
/**
* base include file for SimpleTest
* @package SimpleTest
* @subpackage Extensions
* @author Rene vd O (original code)
* @author Perrick Penet
* @author Marcus Baker
* @version $Id: recorder.php 2011 2011-04-29 08:22:48Z pp11 $
*/
/**
* include other SimpleTest class files
*/
require_once(dirname(__FILE__) . '/scorer.php');
/**
* A single test result.
* @package SimpleTest
* @subpackage Extensions
*/
abstract class SimpleResult {
public $time;
public $breadcrumb;
public $message;
/**
* Records the test result as public members.
* @param array $breadcrumb Test stack at the time of the event.
* @param string $message The messsage to the human.
*/
function __construct($breadcrumb, $message) {
list($this->time, $this->breadcrumb, $this->message) =
array(time(), $breadcrumb, $message);
}
}
/**
* A single pass captured for later.
* @package SimpleTest
* @subpackage Extensions
*/
class SimpleResultOfPass extends SimpleResult { }
/**
* A single failure captured for later.
* @package SimpleTest
* @subpackage Extensions
*/
class SimpleResultOfFail extends SimpleResult { }
/**
* A single exception captured for later.
* @package SimpleTest
* @subpackage Extensions
*/
class SimpleResultOfException extends SimpleResult { }
/**
* Array-based test recorder. Returns an array
* with timestamp, status, test name and message for each pass and failure.
* @package SimpleTest
* @subpackage Extensions
*/
class Recorder extends SimpleReporterDecorator {
public $results = array();
/**
* Stashes the pass as a SimpleResultOfPass
* for later retrieval.
* @param string $message Pass message to be displayed
* eventually.
*/
function paintPass($message) {
parent::paintPass($message);
$this->results[] = new SimpleResultOfPass(parent::getTestList(), $message);
}
/**
* Stashes the fail as a SimpleResultOfFail
* for later retrieval.
* @param string $message Failure message to be displayed
* eventually.
*/
function paintFail($message) {
parent::paintFail($message);
$this->results[] = new SimpleResultOfFail(parent::getTestList(), $message);
}
/**
* Stashes the exception as a SimpleResultOfException
* for later retrieval.
* @param string $message Exception message to be displayed
* eventually.
*/
function paintException($message) {
parent::paintException($message);
$this->results[] = new SimpleResultOfException(parent::getTestList(), $message);
}
}
?>
|