guard-phpunit2 0.2.3 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +5 -1
- data/README.md +16 -7
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/PHPUnit/Extensions/Progress/ResultPrinter.php +503 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/README.markdown +44 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/_files/Number.php +78 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/_files/NumberTest.php +99 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/_files/emptyTest.php +6 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_basic.phpt +22 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_errors.phpt +27 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_errors_variation.phpt +28 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_failing.phpt +31 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_failing_variation.phpt +32 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_incomplete.phpt +19 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_incomplete_variation.phpt +20 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_passing.phpt +19 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_passing_variation.phpt +20 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_skipped.phpt +19 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_skipped_variation.phpt +20 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/VERSION +2 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/phpunit.xml +4 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/screenshot.png +0 -0
- data/lib/guard/phpunit2/formatter.rb +12 -9
- data/lib/guard/phpunit2/notifier.rb +1 -1
- data/lib/guard/phpunit2/runner.rb +25 -12
- data/lib/guard/phpunit2/version.rb +2 -2
- data/lib/guard/phpunit2.rb +1 -0
- data/spec/guard/phpunit2/formatter_spec.rb +4 -4
- data/spec/guard/phpunit2/notifier_spec.rb +4 -4
- data/spec/guard/phpunit2/runner_spec.rb +11 -3
- data/spec/guard/phpunit2_spec.rb +4 -0
- data.tar.gz.sig +0 -0
- metadata +74 -24
- metadata.gz.sig +2 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f96efc03dc54e656212472d776a045c5ad5268e
|
4
|
+
data.tar.gz: ea337d8a51a8ba57c5b5d53101ff0b0fc45be8a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3001101cc7c940c0bbd5a00ea95837c56c6b2f5e47c6b2cf20b91b5a6b5a3a6c86289b13cda46dc0e7ed86131763e4c735da3aebf158648dc9d276c7d9098b47
|
7
|
+
data.tar.gz: 481ecdda28ef0f20f106797adb443f5c0820de6d8bdfd756ab91734c3db4f8f84952a54d0b26c2132f2163e7cd1e27b508aa283c92c4d8fcaa7b23f4427df392
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.1.5 - June 02, 2013
|
2
|
+
- Fixed issues with providing the command
|
3
|
+
- Made it include an explicit output formatter
|
4
|
+
|
1
5
|
## 0.1.4 - August 09, 2012
|
2
6
|
|
3
7
|
- [#2][]: Add support for Windows.
|
@@ -34,4 +38,4 @@
|
|
34
38
|
|
35
39
|
<!--- The following link definition list is generated by PimpMyChangelog --->
|
36
40
|
[#2]: https://github.com/Maher4Ever/guard-phpunit/issues/2
|
37
|
-
[#3]: https://github.com/Maher4Ever/guard-phpunit/issues/3
|
41
|
+
[#3]: https://github.com/Maher4Ever/guard-phpunit/issues/3
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
Guard::PHPUnit [![Build Status](https://secure.travis-ci.org/
|
1
|
+
Guard::PHPUnit [![Build Status](https://secure.travis-ci.org/ramon/guard-phpunit2.png)](http://travis-ci.org/ramon/guard-phpunit2)
|
2
2
|
==============
|
3
3
|
|
4
|
-
Guard-
|
4
|
+
Guard-phpunit2 allows you to automatically run [PHPUnit][6] tests when sources
|
5
5
|
are modified. It helps with integrating test-driven development (TDD) into
|
6
6
|
your development process: Just launch guard-phpunit before you start working
|
7
7
|
and it will notify you about the status of your tests!
|
@@ -18,10 +18,10 @@ you proceed with the installation.
|
|
18
18
|
The latest versions of [Ruby][1] come with a packages-manager called `gem`. `gem` can be used to
|
19
19
|
install various packages, including guard-phpunit.
|
20
20
|
|
21
|
-
To install guard-
|
21
|
+
To install guard-phpunit2, run the following command in the terminal:
|
22
22
|
|
23
23
|
```shell
|
24
|
-
$ gem install guard-
|
24
|
+
$ gem install guard-phpunit2
|
25
25
|
```
|
26
26
|
|
27
27
|
Usage
|
@@ -48,7 +48,7 @@ An example of the Guardfile for the same project would look
|
|
48
48
|
something like:
|
49
49
|
|
50
50
|
```ruby
|
51
|
-
guard '
|
51
|
+
guard 'phpunit2', :tests_path => 'Tests', :cli => '--colors' do
|
52
52
|
# Watch tests files
|
53
53
|
watch(%r{^.+Test\.php$})
|
54
54
|
|
@@ -82,13 +82,17 @@ The following options can be passed to Guard::PHPUnit:
|
|
82
82
|
:cli => '--colors' # The options passed to the phpunit command
|
83
83
|
# when running the tests.
|
84
84
|
# default: nil
|
85
|
+
|
86
|
+
:command => "./bin/phpunit" # specify alternative phpunit location
|
87
|
+
# that is not on the path.
|
88
|
+
# Useful if running phpunit from composer
|
85
89
|
```
|
86
90
|
|
87
91
|
Development
|
88
92
|
-----------
|
89
93
|
|
90
|
-
* Source hosted at [GitHub](https://github.com/
|
91
|
-
* Report issues/Questions/Feature requests on [GitHub Issues](https://github.com/
|
94
|
+
* Source hosted at [GitHub](https://github.com/ramon/guard-phpunit2)
|
95
|
+
* Report issues/Questions/Feature requests on [GitHub Issues](https://github.com/ramon/guard-phpunit2/issues)
|
92
96
|
|
93
97
|
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
|
94
98
|
you make.
|
@@ -98,6 +102,11 @@ Author
|
|
98
102
|
|
99
103
|
[Maher Sallam](https://github.com/Maher4Ever)
|
100
104
|
|
105
|
+
[Ramon Soares](https://github.com/ramon)
|
106
|
+
|
107
|
+
[Marek Kalnik](https://github.com/marekkalnik)
|
108
|
+
|
109
|
+
|
101
110
|
[1]:http://ruby-lang.org
|
102
111
|
[3]:https://github.com/guard/guard#readme
|
103
112
|
[4]:http://www.phpunit.de/manual/current/en/
|
data/lib/guard/phpunit/formatters/PHPUnit-Progress/PHPUnit/Extensions/Progress/ResultPrinter.php
ADDED
@@ -0,0 +1,503 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Prints tests' results in a similar way
|
5
|
+
* to rspec's progress formatter.
|
6
|
+
*
|
7
|
+
* @package PHPUnit
|
8
|
+
* @subpackage Progress
|
9
|
+
* @author Maher Sallam <maher@sallam.me>
|
10
|
+
* @copyright 2011 Maher Sallam <maher@sallam.me>
|
11
|
+
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
12
|
+
* @version 0.1
|
13
|
+
*/
|
14
|
+
class PHPUnit_Extensions_Progress_ResultPrinter extends PHPUnit_TextUI_ResultPrinter {
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Constructor.
|
18
|
+
*
|
19
|
+
* @param mixed $out
|
20
|
+
* @param boolean $verbose
|
21
|
+
* @param boolean $colors
|
22
|
+
* @param boolean $debug
|
23
|
+
*/
|
24
|
+
public function __construct($out = NULL, $verbose = FALSE, $colors = FALSE, $debug = FALSE) {
|
25
|
+
|
26
|
+
// Start capturing output
|
27
|
+
ob_start();
|
28
|
+
|
29
|
+
$argv = $_SERVER['argv'];
|
30
|
+
$colors = in_array('--colors', $argv) || $colors;
|
31
|
+
$verbose = in_array('--verbose', $argv) || in_array('-v', $argv) || $verbose;
|
32
|
+
$debug = in_array('--debug', $argv) || $debug;
|
33
|
+
|
34
|
+
parent::__construct($out, $verbose, $colors, $debug);
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* @param PHPUnit_Framework_TestResult $result
|
39
|
+
*/
|
40
|
+
public function printResult(PHPUnit_Framework_TestResult $result)
|
41
|
+
{
|
42
|
+
print "\n";
|
43
|
+
|
44
|
+
if ($result->errorCount() > 0) {
|
45
|
+
$this->printErrors($result);
|
46
|
+
}
|
47
|
+
|
48
|
+
if ($result->failureCount() > 0) {
|
49
|
+
$this->printFailures($result);
|
50
|
+
}
|
51
|
+
|
52
|
+
if ($this->verbose) {
|
53
|
+
if ($result->deprecatedFeaturesCount() > 0) {
|
54
|
+
if ($result->failureCount() > 0) {
|
55
|
+
print "\n--\n\nDeprecated PHPUnit features are being used";
|
56
|
+
}
|
57
|
+
|
58
|
+
foreach ($result->deprecatedFeatures() as $deprecatedFeature) {
|
59
|
+
$this->write($deprecatedFeature . "\n\n");
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
if ($result->notImplementedCount() > 0) {
|
64
|
+
$this->printIncompletes($result);
|
65
|
+
}
|
66
|
+
|
67
|
+
if ($result->skippedCount() > 0) {
|
68
|
+
$this->printSkipped($result);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
$this->printFooter($result);
|
73
|
+
}
|
74
|
+
|
75
|
+
/**
|
76
|
+
* @param array $defects
|
77
|
+
* @param integer $count
|
78
|
+
* @param string $type
|
79
|
+
*/
|
80
|
+
protected function printDefects(array $defects, $count, $type)
|
81
|
+
{
|
82
|
+
if ($count == 0) {
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
|
86
|
+
$this->write("\n" . $type . ":\n");
|
87
|
+
|
88
|
+
$i = 1;
|
89
|
+
$failOrError = $type == 'Failures' || $type == 'Errors';
|
90
|
+
|
91
|
+
foreach ($defects as $defect) {
|
92
|
+
$this->printDefect($defect, $i++, $failOrError);
|
93
|
+
$this->write("\n");
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
/**
|
98
|
+
* @param PHPUnit_Framework_TestFailure $defect
|
99
|
+
* @param integer $count
|
100
|
+
* @param boolean $failOrError
|
101
|
+
*/
|
102
|
+
protected function printDefect(PHPUnit_Framework_TestFailure $defect, $count, $failOrError = true)
|
103
|
+
{
|
104
|
+
$this->printDefectHeader($defect, $count, $failOrError);
|
105
|
+
|
106
|
+
$padding = str_repeat(' ',
|
107
|
+
4 + ( $failOrError ? strlen((string)$count) : 0 )
|
108
|
+
);
|
109
|
+
|
110
|
+
$this->printDefectBody($defect, $count, $failOrError, $padding);
|
111
|
+
$this->printDefectTrace($defect, $padding);
|
112
|
+
}
|
113
|
+
|
114
|
+
/**
|
115
|
+
* @param PHPUnit_Framework_TestFailure $defect
|
116
|
+
* @param integer $count
|
117
|
+
* @param boolean $failOrError
|
118
|
+
*/
|
119
|
+
protected function printDefectHeader(PHPUnit_Framework_TestFailure $defect, $count, $failOrError = true)
|
120
|
+
{
|
121
|
+
$failedTest = $defect->failedTest();
|
122
|
+
|
123
|
+
if ($failedTest instanceof PHPUnit_Framework_SelfDescribing) {
|
124
|
+
$testName = $failedTest->toString();
|
125
|
+
} else {
|
126
|
+
$testName = get_class($failedTest);
|
127
|
+
}
|
128
|
+
|
129
|
+
if ( $failOrError ) {
|
130
|
+
$this->write(
|
131
|
+
sprintf(
|
132
|
+
"\n %d) %s",
|
133
|
+
|
134
|
+
$count,
|
135
|
+
$testName
|
136
|
+
)
|
137
|
+
);
|
138
|
+
} else {
|
139
|
+
$this->write(
|
140
|
+
sprintf( " %s", $this->yellow($testName) )
|
141
|
+
);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
/**
|
146
|
+
* @param PHPUnit_Framework_TestFailure $defect
|
147
|
+
* @param integer $count
|
148
|
+
* @param boolean $failOrError
|
149
|
+
* @param string $padding
|
150
|
+
*/
|
151
|
+
protected function printDefectBody(PHPUnit_Framework_TestFailure $defect, $count, $failOrError, $padding)
|
152
|
+
{
|
153
|
+
$error = trim($defect->getExceptionAsString());
|
154
|
+
|
155
|
+
if ( !empty($error) ) {
|
156
|
+
$error = explode("\n", $error);
|
157
|
+
$error = "\n" . $padding . implode("\n " . $padding , $error);
|
158
|
+
|
159
|
+
$this->write( $failOrError ? $this->red($error) : $this->cyan($error) );
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
/**
|
164
|
+
* @param PHPUnit_Framework_TestFailure $defect
|
165
|
+
* @param string $padding
|
166
|
+
*/
|
167
|
+
protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect, $padding = 0)
|
168
|
+
{
|
169
|
+
$trace = trim(
|
170
|
+
PHPUnit_Util_Filter::getFilteredStacktrace(
|
171
|
+
$defect->thrownException()
|
172
|
+
)
|
173
|
+
);
|
174
|
+
|
175
|
+
if ( ! empty($trace) ) {
|
176
|
+
$trace = explode("\n", $trace);
|
177
|
+
$trace = "\n" . $padding . '# ' . implode("\n${padding}# ", $trace);
|
178
|
+
|
179
|
+
$this->write($this->cyan($trace));
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
/**
|
184
|
+
* @param PHPUnit_Framework_TestResult $result
|
185
|
+
*/
|
186
|
+
protected function printErrors(PHPUnit_Framework_TestResult $result)
|
187
|
+
{
|
188
|
+
$this->printDefects(
|
189
|
+
$result->errors(),
|
190
|
+
$result->errorCount(),
|
191
|
+
'Errors'
|
192
|
+
);
|
193
|
+
}
|
194
|
+
|
195
|
+
/**
|
196
|
+
* @param PHPUnit_Framework_TestResult $result
|
197
|
+
*/
|
198
|
+
protected function printFailures(PHPUnit_Framework_TestResult $result)
|
199
|
+
{
|
200
|
+
$this->printDefects(
|
201
|
+
$result->failures(),
|
202
|
+
$result->failureCount(),
|
203
|
+
'Failures'
|
204
|
+
);
|
205
|
+
}
|
206
|
+
|
207
|
+
/**
|
208
|
+
* @param PHPUnit_Framework_TestResult $result
|
209
|
+
*/
|
210
|
+
protected function printIncompletes(PHPUnit_Framework_TestResult $result)
|
211
|
+
{
|
212
|
+
$this->printDefects(
|
213
|
+
$result->notImplemented(),
|
214
|
+
$result->notImplementedCount(),
|
215
|
+
'Incomplete tests'
|
216
|
+
);
|
217
|
+
}
|
218
|
+
|
219
|
+
/**
|
220
|
+
* @param PHPUnit_Framework_TestResult $result
|
221
|
+
* @since Method available since Release 3.0.0
|
222
|
+
*/
|
223
|
+
protected function printSkipped(PHPUnit_Framework_TestResult $result)
|
224
|
+
{
|
225
|
+
$this->printDefects(
|
226
|
+
$result->skipped(),
|
227
|
+
$result->skippedCount(),
|
228
|
+
'Skipped tests'
|
229
|
+
);
|
230
|
+
}
|
231
|
+
|
232
|
+
/**
|
233
|
+
* @param PHPUnit_Framework_TestResult $result
|
234
|
+
*/
|
235
|
+
protected function printFooter(PHPUnit_Framework_TestResult $result)
|
236
|
+
{
|
237
|
+
|
238
|
+
$this->write( sprintf("\nFinished in %s\n", PHP_Timer::timeSinceStartOfRequest()) );
|
239
|
+
|
240
|
+
$resultsCount = count($result);
|
241
|
+
|
242
|
+
$footer = sprintf("%d test%s, %d assertion%s",
|
243
|
+
$resultsCount,
|
244
|
+
$resultsCount == 1 ? '' : 's',
|
245
|
+
$this->numAssertions,
|
246
|
+
$this->numAssertions == 1 ? '' : 's'
|
247
|
+
);
|
248
|
+
|
249
|
+
// backwards/forwards compatibility hack for naming fix from phpunit 3.7.11
|
250
|
+
// @see https://github.com/sebastianbergmann/phpunit/issues/762
|
251
|
+
$allCompletelyImplemented = method_exists($result, 'allCompletelyImplemented')?
|
252
|
+
'allCompletelyImplemented':'allCompletlyImplemented';
|
253
|
+
|
254
|
+
if ( $result->wasSuccessful() &&
|
255
|
+
$result->$allCompletelyImplemented() &&
|
256
|
+
$result->noneSkipped() )
|
257
|
+
{
|
258
|
+
$this->write($this->green($footer));
|
259
|
+
}
|
260
|
+
|
261
|
+
else if ( ( !$result->$allCompletelyImplemented() || !$result->noneSkipped() )
|
262
|
+
&&
|
263
|
+
$result->wasSuccessful() )
|
264
|
+
{
|
265
|
+
|
266
|
+
$footer .= sprintf(
|
267
|
+
"%s%s",
|
268
|
+
|
269
|
+
$this->getCountString(
|
270
|
+
$result->notImplementedCount(), 'incomplete'
|
271
|
+
),
|
272
|
+
$this->getCountString(
|
273
|
+
$result->skippedCount(), 'skipped'
|
274
|
+
)
|
275
|
+
);
|
276
|
+
|
277
|
+
$this->write($this->yellow($footer));
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
else {
|
282
|
+
|
283
|
+
$footer .= sprintf(
|
284
|
+
"%s%s%s%s",
|
285
|
+
|
286
|
+
$this->getCountString($result->failureCount(), 'failures'),
|
287
|
+
$this->getCountString($result->errorCount(), 'errors'),
|
288
|
+
$this->getCountString(
|
289
|
+
$result->notImplementedCount(), 'incomplete'
|
290
|
+
),
|
291
|
+
$this->getCountString($result->skippedCount(), 'skipped')
|
292
|
+
);
|
293
|
+
|
294
|
+
$footer = preg_replace('/,$/', '', $footer);
|
295
|
+
|
296
|
+
$this->write($this->red($footer));
|
297
|
+
}
|
298
|
+
|
299
|
+
if ( ! $this->verbose &&
|
300
|
+
$result->deprecatedFeaturesCount() > 0 )
|
301
|
+
{
|
302
|
+
$message = sprintf(
|
303
|
+
"Warning: Deprecated PHPUnit features are being used %s times!\n".
|
304
|
+
"Use --verbose for more information.\n",
|
305
|
+
$result->deprecatedFeaturesCount()
|
306
|
+
);
|
307
|
+
|
308
|
+
if ($this->colors) {
|
309
|
+
$message = "\x1b[37;41m\x1b[2K" . $message .
|
310
|
+
"\x1b[0m";
|
311
|
+
}
|
312
|
+
|
313
|
+
$this->write("\n" . $message);
|
314
|
+
}
|
315
|
+
|
316
|
+
$this->writeNewLine();
|
317
|
+
}
|
318
|
+
|
319
|
+
/**
|
320
|
+
* @param integer $count
|
321
|
+
* @param string $name
|
322
|
+
* @return string
|
323
|
+
* @since Method available since Release 3.0.0
|
324
|
+
*/
|
325
|
+
protected function getCountString($count, $name)
|
326
|
+
{
|
327
|
+
$string = '';
|
328
|
+
|
329
|
+
if ($count > 0) {
|
330
|
+
$string = sprintf(
|
331
|
+
', %d %s',
|
332
|
+
|
333
|
+
$count,
|
334
|
+
$name
|
335
|
+
);
|
336
|
+
}
|
337
|
+
|
338
|
+
return $string;
|
339
|
+
}
|
340
|
+
|
341
|
+
/**
|
342
|
+
* An error occurred.
|
343
|
+
*
|
344
|
+
* @param PHPUnit_Framework_Test $test
|
345
|
+
* @param Exception $e
|
346
|
+
* @param float $time
|
347
|
+
*/
|
348
|
+
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
|
349
|
+
{
|
350
|
+
$this->writeProgress($this->red('E'));
|
351
|
+
$this->lastTestFailed = TRUE;
|
352
|
+
}
|
353
|
+
|
354
|
+
/**
|
355
|
+
* A failure occurred.
|
356
|
+
*
|
357
|
+
* @param PHPUnit_Framework_Test $test
|
358
|
+
* @param PHPUnit_Framework_AssertionFailedError $e
|
359
|
+
* @param float $time
|
360
|
+
*/
|
361
|
+
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
|
362
|
+
{
|
363
|
+
$this->writeProgress($this->red('F'));
|
364
|
+
$this->lastTestFailed = TRUE;
|
365
|
+
}
|
366
|
+
|
367
|
+
/**
|
368
|
+
* Incomplete test.
|
369
|
+
*
|
370
|
+
* @param PHPUnit_Framework_Test $test
|
371
|
+
* @param Exception $e
|
372
|
+
* @param float $time
|
373
|
+
*/
|
374
|
+
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
|
375
|
+
{
|
376
|
+
$this->writeProgress($this->yellow('I'));
|
377
|
+
$this->lastTestFailed = TRUE;
|
378
|
+
}
|
379
|
+
|
380
|
+
/**
|
381
|
+
* Skipped test.
|
382
|
+
*
|
383
|
+
* @param PHPUnit_Framework_Test $test
|
384
|
+
* @param Exception $e
|
385
|
+
* @param float $time
|
386
|
+
* @since Method available since Release 3.0.0
|
387
|
+
*/
|
388
|
+
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
|
389
|
+
{
|
390
|
+
$this->writeProgress($this->yellow('S'));
|
391
|
+
$this->lastTestFailed = TRUE;
|
392
|
+
}
|
393
|
+
|
394
|
+
/**
|
395
|
+
* A test ended.
|
396
|
+
*
|
397
|
+
* @param PHPUnit_Framework_Test $test
|
398
|
+
* @param float $time
|
399
|
+
*/
|
400
|
+
public function endTest(PHPUnit_Framework_Test $test, $time)
|
401
|
+
{
|
402
|
+
if (!$this->lastTestFailed) {
|
403
|
+
$this->writeProgress($this->green('.'));
|
404
|
+
}
|
405
|
+
|
406
|
+
if ($test instanceof PHPUnit_Framework_TestCase) {
|
407
|
+
$this->numAssertions += $test->getNumAssertions();
|
408
|
+
}
|
409
|
+
|
410
|
+
else if ($test instanceof PHPUnit_Extensions_PhptTestCase) {
|
411
|
+
$this->numAssertions++;
|
412
|
+
}
|
413
|
+
|
414
|
+
$this->lastTestFailed = FALSE;
|
415
|
+
|
416
|
+
if ($this->verbose && $test instanceof PHPUnit_Framework_TestCase) {
|
417
|
+
$this->write($test->getActualOutput());
|
418
|
+
}
|
419
|
+
|
420
|
+
}
|
421
|
+
|
422
|
+
/**
|
423
|
+
* @param string $progress
|
424
|
+
*/
|
425
|
+
protected function writeProgress($progress)
|
426
|
+
{
|
427
|
+
static $deletedHeader = false;
|
428
|
+
|
429
|
+
if ( ! $deletedHeader ) {
|
430
|
+
ob_clean();
|
431
|
+
$deletedHeader = true;
|
432
|
+
}
|
433
|
+
|
434
|
+
parent::writeProgress($progress);
|
435
|
+
}
|
436
|
+
|
437
|
+
/**
|
438
|
+
* Returns a colored string which can be used
|
439
|
+
* in the terminal.
|
440
|
+
*
|
441
|
+
* @param string $text
|
442
|
+
* @param integer $color_code
|
443
|
+
*/
|
444
|
+
protected function color($text, $color_code) {
|
445
|
+
return $this->colors ? "\033[${color_code}m" . $text . "\033[0m" : $text;
|
446
|
+
}
|
447
|
+
|
448
|
+
/**
|
449
|
+
* @param string $text
|
450
|
+
*/
|
451
|
+
protected function bold($text) {
|
452
|
+
return $this->color($text, "1");
|
453
|
+
}
|
454
|
+
|
455
|
+
/**
|
456
|
+
* @param string $text
|
457
|
+
*/
|
458
|
+
protected function red($text) {
|
459
|
+
return $this->color($text, "31");
|
460
|
+
}
|
461
|
+
|
462
|
+
/**
|
463
|
+
* @param string $text
|
464
|
+
*/
|
465
|
+
protected function green($text) {
|
466
|
+
return $this->color($text, "32");
|
467
|
+
}
|
468
|
+
|
469
|
+
/**
|
470
|
+
* @param string $text
|
471
|
+
*/
|
472
|
+
protected function yellow($text) {
|
473
|
+
return $this->color($text, "33");
|
474
|
+
}
|
475
|
+
|
476
|
+
/**
|
477
|
+
* @param string $text
|
478
|
+
*/
|
479
|
+
protected function blue($text) {
|
480
|
+
return $this->color($text, "34");
|
481
|
+
}
|
482
|
+
|
483
|
+
/**
|
484
|
+
* @param string $text
|
485
|
+
*/
|
486
|
+
protected function magenta($text) {
|
487
|
+
return $this->color($text, "35");
|
488
|
+
}
|
489
|
+
|
490
|
+
/**
|
491
|
+
* @param string $text
|
492
|
+
*/
|
493
|
+
protected function cyan($text) {
|
494
|
+
return $this->color($text, "36");
|
495
|
+
}
|
496
|
+
|
497
|
+
/**
|
498
|
+
* @param string $text
|
499
|
+
*/
|
500
|
+
protected function white($text) {
|
501
|
+
return $this->color($text, "37");
|
502
|
+
}
|
503
|
+
}
|