Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * $Id: SimpleTestResultFormatter.php 325 2007-12-20 15:44:58Z hans $
4
 *
5
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16
 *
17
 * This software consists of voluntary contributions made by many individuals
18
 * and is licensed under the LGPL. For more information please see
19
 * <http://phing.info>.
20
 */
21
 
22
require_once 'simpletest/scorer.php';
23
 
24
require_once 'phing/system/io/Writer.php';
25
 
26
/**
27
 * This abstract class describes classes that format the results of a SimpleTest testrun.
28
 *
29
 * @author Michiel Rook <michiel.rook@gmail.com>
30
 * @version $Id: SimpleTestResultFormatter.php 325 2007-12-20 15:44:58Z hans $
31
 * @package phing.tasks.ext.phpunit2
32
 * @since 2.2.0
33
 */
34
abstract class SimpleTestResultFormatter extends SimpleReporter
35
{
36
	protected $out = NULL;
37
 
38
	protected $project = NULL;
39
 
40
	private $timer = NULL;
41
 
42
	private $runCount = 0;
43
 
44
	private $failureCount = 0;
45
 
46
	private $errorCount = 0;
47
 
48
	private $currentTest = "";
49
 
50
	/**
51
	 * Sets the writer the formatter is supposed to write its results to.
52
   	 */
53
	function setOutput(Writer $out)
54
	{
55
		$this->out = $out;
56
	}
57
 
58
	/**
59
	 * Returns the extension used for this formatter
60
	 *
61
	 * @return string the extension
62
	 */
63
	function getExtension()
64
	{
65
		return "";
66
	}
67
 
68
	/**
69
	 * Sets the project
70
	 *
71
	 * @param Project the project
72
	 */
73
	function setProject(Project $project)
74
	{
75
		$this->project = $project;
76
	}
77
 
78
	function getPreferredOutfile()
79
	{
80
		return "";
81
	}
82
 
83
	function paintMethodStart($test_name)
84
	{
85
		parent::paintMethodStart($test_name);
86
 
87
		$this->currentTest = $test_name;
88
	}
89
 
90
	function paintMethodEnd($test_name)
91
	{
92
		parent::paintMethodEnd($test_name);
93
 
94
		$this->runCount++;
95
	}
96
 
97
	function paintCaseStart($test_name)
98
	{
99
		parent::paintCaseStart($test_name);
100
 
101
		$this->runCount = 0;
102
		$this->failureCount = 0;
103
		$this->errorCount = 0;
104
 
105
		$this->timer = new Timer();
106
		$this->timer->start();
107
	}
108
 
109
	function paintCaseEnd($test_name)
110
	{
111
		parent::paintCaseEnd($test_name);
112
 
113
		$this->timer->stop();
114
	}
115
 
116
	function paintError($message)
117
	{
118
		parent::paintError($message);
119
 
120
		$this->errorCount++;
121
	}
122
 
123
	function paintFail($message)
124
	{
125
		parent::paintFail($message);
126
 
127
		$this->failureCount++;
128
	}
129
 
130
	function getRunCount()
131
	{
132
		return $this->runCount;
133
	}
134
 
135
	function getFailureCount()
136
	{
137
		return $this->failureCount;
138
	}
139
 
140
	function getErrorCount()
141
	{
142
		return $this->errorCount;
143
	}
144
 
145
	function getTestName()
146
	{
147
		return $this->currentTest;
148
	}
149
 
150
	function getElapsedTime()
151
	{
152
		if ($this->timer)
153
		{
154
			return $this->timer->getElapsedTime();
155
		}
156
		else
157
		{
158
			return 0;
159
		}
160
	}
161
}