1
|
|
|
<?php |
2
|
|
|
namespace Yoanm\PhpUnitExtended\Listener; |
3
|
|
|
|
4
|
|
|
use PHPUnit\Framework\AssertionFailedError; |
5
|
|
|
use PHPUnit\Framework\Test; |
6
|
|
|
use PHPUnit\Framework\TestListener; |
7
|
|
|
use PHPUnit\Framework\TestSuite; |
8
|
|
|
use PHPUnit\Framework\Warning; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Simple listener delegator |
12
|
|
|
*/ |
13
|
|
|
class DelegatingListener implements TestListener |
14
|
|
|
{ |
15
|
|
|
/** TestListener[] */ |
16
|
|
|
private $listenerList = []; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* {@inheritdoc} |
20
|
|
|
*/ |
21
|
11 |
|
public function addListener(TestListener $listener) |
22
|
|
|
{ |
23
|
11 |
|
$this->listenerList[] = $listener; |
24
|
11 |
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @return TestListener[] |
28
|
|
|
*/ |
29
|
1 |
|
public function getListenerList() |
30
|
|
|
{ |
31
|
1 |
|
return $this->listenerList; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
1 |
|
public function addError(Test $test, \Exception $e, $time) |
38
|
|
|
{ |
39
|
1 |
|
foreach ($this->listenerList as $listener) { |
40
|
1 |
|
$listener->addError($test, $e, $time); |
41
|
|
|
} |
42
|
1 |
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritdoc} |
46
|
|
|
*/ |
47
|
1 |
|
public function addWarning(Test $test, Warning $e, $time) |
48
|
|
|
{ |
49
|
1 |
|
foreach ($this->listenerList as $listener) { |
50
|
1 |
|
$listener->addWarning($test, $e, $time); |
51
|
|
|
} |
52
|
1 |
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
1 |
|
public function addFailure(Test $test, AssertionFailedError $e, $time) |
58
|
|
|
{ |
59
|
1 |
|
foreach ($this->listenerList as $listener) { |
60
|
1 |
|
$listener->addFailure($test, $e, $time); |
61
|
|
|
} |
62
|
1 |
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* {@inheritdoc} |
66
|
|
|
*/ |
67
|
1 |
|
public function addIncompleteTest(Test $test, \Exception $e, $time) |
68
|
|
|
{ |
69
|
1 |
|
foreach ($this->listenerList as $listener) { |
70
|
1 |
|
$listener->addIncompleteTest($test, $e, $time); |
71
|
|
|
} |
72
|
1 |
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* {@inheritdoc} |
76
|
|
|
*/ |
77
|
1 |
|
public function addRiskyTest(Test $test, \Exception $e, $time) |
78
|
|
|
{ |
79
|
1 |
|
foreach ($this->listenerList as $listener) { |
80
|
1 |
|
$listener->addRiskyTest($test, $e, $time); |
81
|
|
|
} |
82
|
1 |
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* {@inheritdoc} |
86
|
|
|
*/ |
87
|
1 |
|
public function addSkippedTest(Test $test, \Exception $e, $time) |
88
|
|
|
{ |
89
|
1 |
|
foreach ($this->listenerList as $listener) { |
90
|
1 |
|
$listener->addSkippedTest($test, $e, $time); |
91
|
|
|
} |
92
|
1 |
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* {@inheritdoc} |
96
|
|
|
*/ |
97
|
1 |
|
public function startTestSuite(TestSuite $suite) |
98
|
|
|
{ |
99
|
1 |
|
foreach ($this->listenerList as $listener) { |
100
|
1 |
|
$listener->startTestSuite($suite); |
101
|
|
|
} |
102
|
1 |
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* {@inheritdoc} |
106
|
|
|
*/ |
107
|
1 |
|
public function endTestSuite(TestSuite $suite) |
108
|
|
|
{ |
109
|
1 |
|
foreach ($this->listenerList as $listener) { |
110
|
1 |
|
$listener->endTestSuite($suite); |
111
|
|
|
} |
112
|
1 |
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* {@inheritdoc} |
116
|
|
|
*/ |
117
|
1 |
|
public function startTest(Test $test) |
118
|
|
|
{ |
119
|
1 |
|
foreach ($this->listenerList as $listener) { |
120
|
1 |
|
$listener->startTest($test); |
121
|
|
|
} |
122
|
1 |
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* {@inheritdoc} |
126
|
|
|
*/ |
127
|
1 |
|
public function endTest(Test $test, $time) |
128
|
|
|
{ |
129
|
1 |
|
foreach ($this->listenerList as $listener) { |
130
|
1 |
|
$listener->endTest($test, $time); |
131
|
|
|
} |
132
|
1 |
|
} |
133
|
|
|
} |
134
|
|
|
|