5
5
*/
6
6
namespace Magento \TestFramework \Listener ;
7
7
8
- class ExtededTestdox extends \PHPUnit_Util_Printer implements \PHPUnit \Framework \TestListener
8
+ use PHPUnit \Framework \AssertionFailedError ;
9
+ use PHPUnit \Framework \Test ;
10
+ use PHPUnit \Framework \TestCase ;
11
+ use PHPUnit \Framework \TestListener ;
12
+ use PHPUnit \Framework \TestSuite ;
13
+ use PHPUnit \Runner \BaseTestRunner ;
14
+ use PHPUnit \Util \Printer ;
15
+ use PHPUnit \Util \TestDox \NamePrettifier ;
16
+
17
+ class ExtededTestdox extends Printer implements TestListener
9
18
{
10
19
/**
11
- * @var \PHPUnit_Util_TestDox_NamePrettifier
20
+ * @var NamePrettifier
12
21
*/
13
22
protected $ prettifier ;
14
23
@@ -55,7 +64,7 @@ class ExtededTestdox extends \PHPUnit_Util_Printer implements \PHPUnit\Framework
55
64
/**
56
65
* @var \stdClass
57
66
*/
58
- protected $ testTypeOfInterest = \ PHPUnit \ Framework \ TestCase::class;
67
+ protected $ testTypeOfInterest = TestCase::class;
59
68
60
69
/**
61
70
* @var string
@@ -76,7 +85,7 @@ public function __construct($out = null)
76
85
{
77
86
parent ::__construct ($ out );
78
87
79
- $ this ->prettifier = new \ PHPUnit_Util_TestDox_NamePrettifier ();
88
+ $ this ->prettifier = new NamePrettifier ();
80
89
$ this ->startRun ();
81
90
}
82
91
@@ -95,113 +104,113 @@ public function flush()
95
104
/**
96
105
* An error occurred.
97
106
*
98
- * @param \PHPUnit\Framework\ Test $test
107
+ * @param Test $test
99
108
* @param \Exception $e
100
109
* @param float $time
101
110
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
102
111
*/
103
- public function addError (\ PHPUnit \ Framework \ Test $ test , \Exception $ e , $ time )
112
+ public function addError (Test $ test , \Throwable $ e , float $ time ): void
104
113
{
105
114
if ($ test instanceof $ this ->testTypeOfInterest ) {
106
- $ this ->testStatus = \PHPUnit_Runner_BaseTestRunner ::STATUS_ERROR ;
115
+ $ this ->testStatus = BaseTestRunner ::STATUS_ERROR ;
107
116
$ this ->failed ++;
108
117
}
109
118
}
110
119
111
120
/**
112
121
* A failure occurred.
113
122
*
114
- * @param \PHPUnit\Framework\ Test $test
115
- * @param \PHPUnit\Framework\ AssertionFailedError $e
123
+ * @param Test $test
124
+ * @param AssertionFailedError $e
116
125
* @param float $time
117
126
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
118
127
*/
119
- public function addFailure (\ PHPUnit \ Framework \ Test $ test , \ PHPUnit \ Framework \ AssertionFailedError $ e , $ time )
128
+ public function addFailure (Test $ test , AssertionFailedError $ e , float $ time ): void
120
129
{
121
130
if ($ test instanceof $ this ->testTypeOfInterest ) {
122
- $ this ->testStatus = \PHPUnit_Runner_BaseTestRunner ::STATUS_FAILURE ;
131
+ $ this ->testStatus = BaseTestRunner ::STATUS_FAILURE ;
123
132
$ this ->failed ++;
124
133
}
125
134
}
126
135
127
136
/**
128
137
* Incomplete test.
129
138
*
130
- * @param \PHPUnit\Framework\ Test $test
139
+ * @param Test $test
131
140
* @param \Exception $e
132
141
* @param float $time
133
142
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
134
143
*/
135
- public function addIncompleteTest (\ PHPUnit \ Framework \ Test $ test , \Exception $ e , $ time )
144
+ public function addIncompleteTest (Test $ test , \Throwable $ e , float $ time ): void
136
145
{
137
146
if ($ test instanceof $ this ->testTypeOfInterest ) {
138
- $ this ->testStatus = \PHPUnit_Runner_BaseTestRunner ::STATUS_INCOMPLETE ;
147
+ $ this ->testStatus = BaseTestRunner ::STATUS_INCOMPLETE ;
139
148
$ this ->incomplete ++;
140
149
}
141
150
}
142
151
143
152
/**
144
153
* Skipped test.
145
154
*
146
- * @param \PHPUnit\Framework\ Test $test
155
+ * @param Test $test
147
156
* @param \Exception $e
148
157
* @param float $time
149
158
* @since Method available since Release 3.0.0
150
159
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
151
160
*/
152
- public function addSkippedTest (\ PHPUnit \ Framework \ Test $ test , \Exception $ e , $ time )
161
+ public function addSkippedTest (Test $ test , \Throwable $ e , float $ time ): void
153
162
{
154
163
if ($ test instanceof $ this ->testTypeOfInterest ) {
155
- $ this ->testStatus = \PHPUnit_Runner_BaseTestRunner ::STATUS_SKIPPED ;
164
+ $ this ->testStatus = BaseTestRunner ::STATUS_SKIPPED ;
156
165
$ this ->skipped ++;
157
166
}
158
167
}
159
168
160
169
/**
161
170
* Risky test.
162
171
*
163
- * @param \PHPUnit\Framework\ Test $test
172
+ * @param Test $test
164
173
* @param \Exception $e
165
174
* @param float $time
166
175
* @since Method available since Release 4.0.0
167
176
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
168
177
*/
169
- public function addRiskyTest (\ PHPUnit \ Framework \ Test $ test , \Exception $ e , $ time )
178
+ public function addRiskyTest (Test $ test , \Throwable $ e , float $ time ): void
170
179
{
171
180
if ($ test instanceof $ this ->testTypeOfInterest ) {
172
- $ this ->testStatus = \PHPUnit_Runner_BaseTestRunner ::STATUS_RISKY ;
181
+ $ this ->testStatus = BaseTestRunner ::STATUS_RISKY ;
173
182
$ this ->risky ++;
174
183
}
175
184
}
176
185
177
186
/**
178
187
* A testsuite started.
179
188
*
180
- * @param \PHPUnit\Framework\ TestSuite $suite
189
+ * @param TestSuite $suite
181
190
* @since Method available since Release 2.2.0
182
191
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
183
192
*/
184
- public function startTestSuite (\ PHPUnit \ Framework \ TestSuite $ suite )
193
+ public function startTestSuite (TestSuite $ suite ): void
185
194
{
186
195
}
187
196
188
197
/**
189
198
* A testsuite ended.
190
199
*
191
- * @param \PHPUnit\Framework\ TestSuite $suite
200
+ * @param TestSuite $suite
192
201
* @since Method available since Release 2.2.0
193
202
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
194
203
*/
195
- public function endTestSuite (\ PHPUnit \ Framework \ TestSuite $ suite )
204
+ public function endTestSuite (TestSuite $ suite ): void
196
205
{
197
206
}
198
207
199
208
/**
200
209
* A test started.
201
210
*
202
- * @param \PHPUnit\Framework\ Test $test
211
+ * @param Test $test
203
212
*/
204
- public function startTest (\ PHPUnit \ Framework \ Test $ test )
213
+ public function startTest (Test $ test ): void
205
214
{
206
215
if ($ test instanceof $ this ->testTypeOfInterest ) {
207
216
$ class = get_class ($ test );
@@ -220,30 +229,30 @@ public function startTest(\PHPUnit\Framework\Test $test)
220
229
$ this ->write ('. ' );
221
230
$ this ->currentTestMethodPrettified = $ this ->prettifier ->prettifyTestMethod ($ test ->getName (false ));
222
231
223
- $ this ->testStatus = \PHPUnit_Runner_BaseTestRunner ::STATUS_PASSED ;
232
+ $ this ->testStatus = BaseTestRunner ::STATUS_PASSED ;
224
233
}
225
234
}
226
235
227
236
/**
228
237
* A test ended.
229
238
*
230
- * @param \PHPUnit\Framework\ Test $test
239
+ * @param Test $test
231
240
* @param float $time
232
241
*/
233
- public function endTest (\ PHPUnit \ Framework \ Test $ test , $ time )
242
+ public function endTest (Test $ test , float $ time ): void
234
243
{
235
244
if ($ test instanceof $ this ->testTypeOfInterest ) {
236
245
if (!isset ($ this ->tests [$ this ->currentTestMethodPrettified ])) {
237
246
$ this ->tests [$ this ->currentTestMethodPrettified ] = ['success ' => 0 , 'failure ' => 0 , 'time ' => 0 ];
238
247
}
239
248
240
- if ($ this ->testStatus == \PHPUnit_Runner_BaseTestRunner ::STATUS_PASSED ) {
249
+ if ($ this ->testStatus == BaseTestRunner ::STATUS_PASSED ) {
241
250
$ this ->tests [$ this ->currentTestMethodPrettified ]['success ' ]++;
242
251
}
243
- if ($ this ->testStatus == \PHPUnit_Runner_BaseTestRunner ::STATUS_ERROR ) {
252
+ if ($ this ->testStatus == BaseTestRunner ::STATUS_ERROR ) {
244
253
$ this ->tests [$ this ->currentTestMethodPrettified ]['failure ' ]++;
245
254
}
246
- if ($ this ->testStatus == \PHPUnit_Runner_BaseTestRunner ::STATUS_FAILURE ) {
255
+ if ($ this ->testStatus == BaseTestRunner ::STATUS_FAILURE ) {
247
256
$ this ->tests [$ this ->currentTestMethodPrettified ]['failure ' ]++;
248
257
}
249
258
$ this ->tests [$ this ->currentTestMethodPrettified ]['time ' ] += $ time ;
@@ -256,15 +265,15 @@ public function endTest(\PHPUnit\Framework\Test $test, $time)
256
265
* Handler for 'start run' event.
257
266
*
258
267
*/
259
- protected function startRun ()
268
+ protected function startRun (): void
260
269
{
261
270
}
262
271
263
272
/**
264
273
* Handler for 'end run' event.
265
274
*
266
275
*/
267
- protected function endRun ()
276
+ protected function endRun (): void
268
277
{
269
278
}
270
279
@@ -274,7 +283,7 @@ protected function endRun()
274
283
* @param string $name
275
284
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
276
285
*/
277
- protected function startClass ($ name )
286
+ protected function startClass ($ name ): void
278
287
{
279
288
$ this ->write ($ this ->currentTestClassPrettified . ' ' );
280
289
}
@@ -285,15 +294,15 @@ protected function startClass($name)
285
294
* @param string $name
286
295
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
287
296
*/
288
- protected function endClass ($ name )
297
+ protected function endClass ($ name ): void
289
298
{
290
299
$ this ->write ("\n" );
291
300
}
292
301
293
302
/**
294
303
* @since Method available since Release 2.3.0
295
304
*/
296
- protected function doEndClass ()
305
+ protected function doEndClass (): void
297
306
{
298
307
foreach ($ this ->tests as $ name => $ data ) {
299
308
$ check = $ data ['failure ' ] == 0 ? ' - [x] ' : ' - [ ] ' ;
0 commit comments