1
|
|
|
<?php |
2
|
|
|
namespace Yoanm\PhpUnitExtended\Listener; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Simple listener delegator |
6
|
|
|
*/ |
7
|
|
|
class DelegatingListener implements \PHPUnit_Framework_TestListener |
8
|
|
|
{ |
9
|
|
|
/** \PHPUnit_Framework_TestListener[] */ |
10
|
|
|
private $listenerList = []; |
11
|
|
|
|
12
|
10 |
|
public function addListener(\PHPUnit_Framework_TestListener $listener) |
13
|
|
|
{ |
14
|
10 |
|
$this->listenerList[] = $listener; |
15
|
10 |
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @return \PHPUnit_Framework_TestListener[] |
19
|
|
|
*/ |
20
|
1 |
|
public function getListenerList() |
21
|
|
|
{ |
22
|
1 |
|
return $this->listenerList; |
23
|
|
|
} |
24
|
|
|
|
25
|
1 |
|
public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time) |
26
|
|
|
{ |
27
|
1 |
|
foreach ($this->listenerList as $listener) { |
28
|
1 |
|
$listener->addError($test, $e, $time); |
29
|
1 |
|
} |
30
|
1 |
|
} |
31
|
|
|
|
32
|
1 |
|
public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time) |
33
|
|
|
{ |
34
|
1 |
|
foreach ($this->listenerList as $listener) { |
35
|
1 |
|
$listener->addFailure($test, $e, $time); |
36
|
1 |
|
} |
37
|
1 |
|
} |
38
|
|
|
|
39
|
1 |
|
public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) |
40
|
|
|
{ |
41
|
1 |
|
foreach ($this->listenerList as $listener) { |
42
|
1 |
|
$listener->addIncompleteTest($test, $e, $time); |
43
|
1 |
|
} |
44
|
1 |
|
} |
45
|
|
|
|
46
|
1 |
|
public function addRiskyTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) |
47
|
|
|
{ |
48
|
1 |
|
foreach ($this->listenerList as $listener) { |
49
|
1 |
|
$listener->addRiskyTest($test, $e, $time); |
50
|
1 |
|
} |
51
|
1 |
|
} |
52
|
|
|
|
53
|
1 |
|
public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) |
54
|
|
|
{ |
55
|
1 |
|
foreach ($this->listenerList as $listener) { |
56
|
1 |
|
$listener->addSkippedTest($test, $e, $time); |
57
|
1 |
|
} |
58
|
1 |
|
} |
59
|
|
|
|
60
|
1 |
|
public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) |
61
|
|
|
{ |
62
|
1 |
|
foreach ($this->listenerList as $listener) { |
63
|
1 |
|
$listener->startTestSuite($suite); |
64
|
1 |
|
} |
65
|
1 |
|
} |
66
|
|
|
|
67
|
1 |
|
public function endTestSuite(\PHPUnit_Framework_TestSuite $suite) |
68
|
|
|
{ |
69
|
1 |
|
foreach ($this->listenerList as $listener) { |
70
|
1 |
|
$listener->endTestSuite($suite); |
71
|
1 |
|
} |
72
|
1 |
|
} |
73
|
|
|
|
74
|
1 |
|
public function startTest(\PHPUnit_Framework_Test $test) |
75
|
|
|
{ |
76
|
1 |
|
foreach ($this->listenerList as $listener) { |
77
|
1 |
|
$listener->startTest($test); |
78
|
1 |
|
} |
79
|
1 |
|
} |
80
|
|
|
|
81
|
1 |
|
public function endTest(\PHPUnit_Framework_Test $test, $time) |
82
|
|
|
{ |
83
|
1 |
|
foreach ($this->listenerList as $listener) { |
84
|
1 |
|
$listener->endTest($test, $time); |
85
|
1 |
|
} |
86
|
1 |
|
} |
87
|
|
|
} |
88
|
|
|
|