1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of PHPUnit. |
4
|
|
|
* |
5
|
|
|
* (c) Sebastian Bergmann <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
namespace PHPUnit\TextUI; |
11
|
|
|
|
12
|
|
|
use PHPUnit\Framework\Error\Deprecated; |
13
|
|
|
use PHPUnit\Framework\Error\Notice; |
14
|
|
|
use PHPUnit\Framework\Error\Warning; |
15
|
|
|
use PHPUnit\Framework\Exception; |
16
|
|
|
use PHPUnit\Framework\Test; |
17
|
|
|
use PHPUnit\Framework\TestCase; |
18
|
|
|
use PHPUnit\Framework\TestListener; |
19
|
|
|
use PHPUnit\Framework\TestResult; |
20
|
|
|
use PHPUnit\Framework\TestSuite; |
21
|
|
|
use PHPUnit\Runner\AfterLastTestHook; |
22
|
|
|
use PHPUnit\Runner\BaseTestRunner; |
23
|
|
|
use PHPUnit\Runner\BeforeFirstTestHook; |
24
|
|
|
use PHPUnit\Runner\Filter\ExcludeGroupFilterIterator; |
25
|
|
|
use PHPUnit\Runner\Filter\Factory; |
26
|
|
|
use PHPUnit\Runner\Filter\IncludeGroupFilterIterator; |
27
|
|
|
use PHPUnit\Runner\Filter\NameFilterIterator; |
28
|
|
|
use PHPUnit\Runner\Hook; |
29
|
|
|
use PHPUnit\Runner\NullTestResultCache; |
30
|
|
|
use PHPUnit\Runner\ResultCacheExtension; |
31
|
|
|
use PHPUnit\Runner\StandardTestSuiteLoader; |
32
|
|
|
use PHPUnit\Runner\TestHook; |
33
|
|
|
use PHPUnit\Runner\TestListenerAdapter; |
34
|
|
|
use PHPUnit\Runner\TestResultCache; |
35
|
|
|
use PHPUnit\Runner\TestSuiteLoader; |
36
|
|
|
use PHPUnit\Runner\TestSuiteSorter; |
37
|
|
|
use PHPUnit\Runner\Version; |
38
|
|
|
use PHPUnit\Util\Configuration; |
39
|
|
|
use PHPUnit\Util\Filesystem; |
40
|
|
|
use PHPUnit\Util\Log\JUnit; |
41
|
|
|
use PHPUnit\Util\Log\TeamCity; |
42
|
|
|
use PHPUnit\Util\Printer; |
43
|
|
|
use PHPUnit\Util\TestDox\CliTestDoxPrinter; |
44
|
|
|
use PHPUnit\Util\TestDox\HtmlResultPrinter; |
45
|
|
|
use PHPUnit\Util\TestDox\TextResultPrinter; |
46
|
|
|
use PHPUnit\Util\TestDox\XmlResultPrinter; |
47
|
|
|
use PHPUnit\Util\XdebugFilterScriptGenerator; |
48
|
|
|
use ReflectionClass; |
49
|
|
|
use SebastianBergmann\CodeCoverage\CodeCoverage; |
50
|
|
|
use SebastianBergmann\CodeCoverage\Exception as CodeCoverageException; |
51
|
|
|
use SebastianBergmann\CodeCoverage\Filter as CodeCoverageFilter; |
52
|
|
|
use SebastianBergmann\CodeCoverage\Report\Clover as CloverReport; |
53
|
|
|
use SebastianBergmann\CodeCoverage\Report\Crap4j as Crap4jReport; |
54
|
|
|
use SebastianBergmann\CodeCoverage\Report\Html\Facade as HtmlReport; |
55
|
|
|
use SebastianBergmann\CodeCoverage\Report\PHP as PhpReport; |
56
|
|
|
use SebastianBergmann\CodeCoverage\Report\Text as TextReport; |
57
|
|
|
use SebastianBergmann\CodeCoverage\Report\Xml\Facade as XmlReport; |
58
|
|
|
use SebastianBergmann\Comparator\Comparator; |
59
|
|
|
use SebastianBergmann\Environment\Runtime; |
60
|
|
|
use SebastianBergmann\Invoker\Invoker; |
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* A TestRunner for the Command Line Interface (CLI) |
64
|
|
|
* PHP SAPI Module. |
65
|
|
|
*/ |
66
|
|
|
class TestRunner extends BaseTestRunner |
67
|
|
|
{ |
68
|
|
|
public const SUCCESS_EXIT = 0; |
69
|
|
|
|
70
|
|
|
public const FAILURE_EXIT = 1; |
71
|
|
|
|
72
|
|
|
public const EXCEPTION_EXIT = 2; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var bool |
76
|
|
|
*/ |
77
|
|
|
protected static $versionStringPrinted = false; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @var CodeCoverageFilter |
81
|
|
|
*/ |
82
|
|
|
protected $codeCoverageFilter; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @var TestSuiteLoader |
86
|
|
|
*/ |
87
|
|
|
protected $loader; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @var ResultPrinter |
91
|
|
|
*/ |
92
|
|
|
protected $printer; |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @var Runtime |
96
|
|
|
*/ |
97
|
|
|
private $runtime; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @var bool |
101
|
|
|
*/ |
102
|
|
|
private $messagePrinted = false; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @var Hook[] |
106
|
|
|
*/ |
107
|
|
|
private $extensions = []; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param ReflectionClass|Test $test |
111
|
|
|
* @param bool $exit |
112
|
|
|
* |
113
|
|
|
* @throws \RuntimeException |
114
|
|
|
* @throws \InvalidArgumentException |
115
|
|
|
* @throws Exception |
116
|
|
|
* @throws \ReflectionException |
117
|
|
|
*/ |
118
|
|
|
public static function run($test, array $arguments = [], $exit = true): TestResult |
119
|
|
|
{ |
120
|
|
|
if ($test instanceof ReflectionClass) { |
121
|
|
|
$test = new TestSuite($test); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
if ($test instanceof Test) { |
|
|
|
|
125
|
|
|
$aTestRunner = new self; |
126
|
|
|
|
127
|
|
|
return $aTestRunner->doRun( |
128
|
|
|
$test, |
129
|
|
|
$arguments, |
130
|
|
|
$exit |
131
|
|
|
); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
throw new Exception('No test case or test suite found.'); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function __construct(TestSuiteLoader $loader = null, CodeCoverageFilter $filter = null) |
138
|
|
|
{ |
139
|
|
|
if ($filter === null) { |
140
|
|
|
$filter = new CodeCoverageFilter; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
$this->codeCoverageFilter = $filter; |
144
|
|
|
$this->loader = $loader; |
145
|
|
|
$this->runtime = new Runtime; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @throws \PHPUnit\Runner\Exception |
150
|
|
|
* @throws Exception |
151
|
|
|
* @throws \InvalidArgumentException |
152
|
|
|
* @throws \RuntimeException |
153
|
|
|
* @throws \ReflectionException |
154
|
|
|
*/ |
155
|
|
|
public function doRun(Test $suite, array $arguments = [], bool $exit = true): TestResult |
156
|
|
|
{ |
157
|
|
|
if (isset($arguments['configuration'])) { |
158
|
|
|
$GLOBALS['__PHPUNIT_CONFIGURATION_FILE'] = $arguments['configuration']; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
$this->handleConfiguration($arguments); |
162
|
|
|
|
163
|
|
|
if (\is_int($arguments['columns']) && $arguments['columns'] < 16) { |
164
|
|
|
$arguments['columns'] = 16; |
165
|
|
|
$tooFewColumnsRequested = true; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
if (isset($arguments['bootstrap'])) { |
169
|
|
|
$GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap']; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
if ($suite instanceof TestCase || $suite instanceof TestSuite) { |
173
|
|
|
if ($arguments['backupGlobals'] === true) { |
174
|
|
|
$suite->setBackupGlobals(true); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
if ($arguments['backupStaticAttributes'] === true) { |
178
|
|
|
$suite->setBackupStaticAttributes(true); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
if ($arguments['beStrictAboutChangesToGlobalState'] === true) { |
182
|
|
|
$suite->setBeStrictAboutChangesToGlobalState(true); |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
if ($arguments['executionOrder'] === TestSuiteSorter::ORDER_RANDOMIZED) { |
187
|
|
|
\mt_srand($arguments['randomOrderSeed']); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
if ($arguments['cacheResult']) { |
191
|
|
|
if (!isset($arguments['cacheResultFile'])) { |
192
|
|
|
if ($arguments['configuration'] instanceof Configuration) { |
193
|
|
|
$cacheLocation = $arguments['configuration']->getFilename(); |
194
|
|
|
} else { |
195
|
|
|
$cacheLocation = $_SERVER['PHP_SELF']; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
$arguments['cacheResultFile'] = null; |
199
|
|
|
|
200
|
|
|
$cacheResultFile = \realpath($cacheLocation); |
201
|
|
|
|
202
|
|
|
if ($cacheResultFile !== false) { |
203
|
|
|
$arguments['cacheResultFile'] = \dirname($cacheResultFile); |
204
|
|
|
} |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
$cache = new TestResultCache($arguments['cacheResultFile']); |
208
|
|
|
$this->extensions[] = new ResultCacheExtension($cache); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
if ($arguments['executionOrder'] !== TestSuiteSorter::ORDER_DEFAULT || $arguments['executionOrderDefects'] !== TestSuiteSorter::ORDER_DEFAULT || $arguments['resolveDependencies']) { |
212
|
|
|
$cache = $cache ?? new NullTestResultCache; |
213
|
|
|
|
214
|
|
|
$cache->load(); |
215
|
|
|
|
216
|
|
|
$sorter = new TestSuiteSorter($cache); |
217
|
|
|
|
218
|
|
|
$sorter->reorderTestsInSuite($suite, $arguments['executionOrder'], $arguments['resolveDependencies'], $arguments['executionOrderDefects']); |
219
|
|
|
$originalExecutionOrder = $sorter->getOriginalExecutionOrder(); |
220
|
|
|
|
221
|
|
|
unset($sorter); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
if (\is_int($arguments['repeat']) && $arguments['repeat'] > 0) { |
225
|
|
|
$_suite = new TestSuite; |
226
|
|
|
|
227
|
|
|
foreach (\range(1, $arguments['repeat']) as $step) { |
228
|
|
|
$_suite->addTest($suite); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
$suite = $_suite; |
232
|
|
|
|
233
|
|
|
unset($_suite); |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
$result = $this->createTestResult(); |
237
|
|
|
|
238
|
|
|
$listener = new TestListenerAdapter; |
239
|
|
|
$listenerNeeded = false; |
240
|
|
|
|
241
|
|
|
foreach ($this->extensions as $extension) { |
242
|
|
|
if ($extension instanceof TestHook) { |
243
|
|
|
$listener->add($extension); |
244
|
|
|
|
245
|
|
|
$listenerNeeded = true; |
246
|
|
|
} |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
if ($listenerNeeded) { |
250
|
|
|
$result->addListener($listener); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
unset($listener, $listenerNeeded); |
254
|
|
|
|
255
|
|
|
if (!$arguments['convertErrorsToExceptions']) { |
256
|
|
|
$result->convertErrorsToExceptions(false); |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
if (!$arguments['convertDeprecationsToExceptions']) { |
260
|
|
|
Deprecated::$enabled = false; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
if (!$arguments['convertNoticesToExceptions']) { |
264
|
|
|
Notice::$enabled = false; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
if (!$arguments['convertWarningsToExceptions']) { |
268
|
|
|
Warning::$enabled = false; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
if ($arguments['stopOnError']) { |
272
|
|
|
$result->stopOnError(true); |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
if ($arguments['stopOnFailure']) { |
276
|
|
|
$result->stopOnFailure(true); |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
if ($arguments['stopOnWarning']) { |
280
|
|
|
$result->stopOnWarning(true); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
if ($arguments['stopOnIncomplete']) { |
284
|
|
|
$result->stopOnIncomplete(true); |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
if ($arguments['stopOnRisky']) { |
288
|
|
|
$result->stopOnRisky(true); |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
if ($arguments['stopOnSkipped']) { |
292
|
|
|
$result->stopOnSkipped(true); |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
if ($arguments['stopOnDefect']) { |
296
|
|
|
$result->stopOnDefect(true); |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
if ($arguments['registerMockObjectsFromTestArgumentsRecursively']) { |
300
|
|
|
$result->setRegisterMockObjectsFromTestArgumentsRecursively(true); |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
if ($this->printer === null) { |
304
|
|
|
if (isset($arguments['printer']) && |
305
|
|
|
$arguments['printer'] instanceof Printer) { |
306
|
|
|
$this->printer = $arguments['printer']; |
307
|
|
|
} else { |
308
|
|
|
$printerClass = ResultPrinter::class; |
309
|
|
|
|
310
|
|
|
if (isset($arguments['printer']) && \is_string($arguments['printer']) && \class_exists($arguments['printer'], false)) { |
311
|
|
|
$class = new ReflectionClass($arguments['printer']); |
312
|
|
|
|
313
|
|
|
if ($class->isSubclassOf(ResultPrinter::class)) { |
314
|
|
|
$printerClass = $arguments['printer']; |
315
|
|
|
} |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
$this->printer = new $printerClass( |
319
|
|
|
(isset($arguments['stderr']) && $arguments['stderr'] === true) ? 'php://stderr' : null, |
320
|
|
|
$arguments['verbose'], |
321
|
|
|
$arguments['colors'], |
322
|
|
|
$arguments['debug'], |
323
|
|
|
$arguments['columns'], |
324
|
|
|
$arguments['reverseList'] |
325
|
|
|
); |
326
|
|
|
|
327
|
|
|
if (isset($originalExecutionOrder) && ($this->printer instanceof CliTestDoxPrinter)) { |
328
|
|
|
/* @var CliTestDoxPrinter */ |
329
|
|
|
$this->printer->setOriginalExecutionOrder($originalExecutionOrder); |
|
|
|
|
330
|
|
|
} |
331
|
|
|
} |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
$this->printer->write( |
335
|
|
|
Version::getVersionString() . "\n" |
336
|
|
|
); |
337
|
|
|
|
338
|
|
|
self::$versionStringPrinted = true; |
339
|
|
|
|
340
|
|
|
if ($arguments['verbose']) { |
341
|
|
|
$runtime = $this->runtime->getNameWithVersion(); |
342
|
|
|
|
343
|
|
|
if ($this->runtime->hasXdebug()) { |
344
|
|
|
$runtime .= \sprintf( |
345
|
|
|
' with Xdebug %s', |
346
|
|
|
\phpversion('xdebug') |
347
|
|
|
); |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
$this->writeMessage('Runtime', $runtime); |
351
|
|
|
|
352
|
|
|
if (isset($arguments['configuration'])) { |
353
|
|
|
$this->writeMessage( |
354
|
|
|
'Configuration', |
355
|
|
|
$arguments['configuration']->getFilename() |
356
|
|
|
); |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
foreach ($arguments['loadedExtensions'] as $extension) { |
360
|
|
|
$this->writeMessage( |
361
|
|
|
'Extension', |
362
|
|
|
$extension |
363
|
|
|
); |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
foreach ($arguments['notLoadedExtensions'] as $extension) { |
367
|
|
|
$this->writeMessage( |
368
|
|
|
'Extension', |
369
|
|
|
$extension |
370
|
|
|
); |
371
|
|
|
} |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
if ($arguments['executionOrder'] === TestSuiteSorter::ORDER_RANDOMIZED) { |
375
|
|
|
$this->writeMessage( |
376
|
|
|
'Random seed', |
377
|
|
|
$arguments['randomOrderSeed'] |
378
|
|
|
); |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
if (isset($tooFewColumnsRequested)) { |
382
|
|
|
$this->writeMessage('Error', 'Less than 16 columns requested, number of columns set to 16'); |
383
|
|
|
} |
384
|
|
|
|
385
|
|
|
if ($this->runtime->discardsComments()) { |
386
|
|
|
$this->writeMessage('Warning', 'opcache.save_comments=0 set; annotations will not work'); |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
if (isset($arguments['configuration']) && $arguments['configuration']->hasValidationErrors()) { |
390
|
|
|
$this->write( |
391
|
|
|
"\n Warning - The configuration file did not pass validation!\n The following problems have been detected:\n" |
392
|
|
|
); |
393
|
|
|
|
394
|
|
|
foreach ($arguments['configuration']->getValidationErrors() as $line => $errors) { |
395
|
|
|
$this->write(\sprintf("\n Line %d:\n", $line)); |
396
|
|
|
|
397
|
|
|
foreach ($errors as $msg) { |
398
|
|
|
$this->write(\sprintf(" - %s\n", $msg)); |
399
|
|
|
} |
400
|
|
|
} |
401
|
|
|
$this->write("\n Test results may not be as expected.\n\n"); |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
foreach ($arguments['listeners'] as $listener) { |
405
|
|
|
$result->addListener($listener); |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
$result->addListener($this->printer); |
409
|
|
|
|
410
|
|
|
$codeCoverageReports = 0; |
411
|
|
|
|
412
|
|
|
if (!isset($arguments['noLogging'])) { |
413
|
|
|
if (isset($arguments['testdoxHTMLFile'])) { |
414
|
|
|
$result->addListener( |
415
|
|
|
new HtmlResultPrinter( |
416
|
|
|
$arguments['testdoxHTMLFile'], |
417
|
|
|
$arguments['testdoxGroups'], |
418
|
|
|
$arguments['testdoxExcludeGroups'] |
419
|
|
|
) |
420
|
|
|
); |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
if (isset($arguments['testdoxTextFile'])) { |
424
|
|
|
$result->addListener( |
425
|
|
|
new TextResultPrinter( |
426
|
|
|
$arguments['testdoxTextFile'], |
427
|
|
|
$arguments['testdoxGroups'], |
428
|
|
|
$arguments['testdoxExcludeGroups'] |
429
|
|
|
) |
430
|
|
|
); |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
if (isset($arguments['testdoxXMLFile'])) { |
434
|
|
|
$result->addListener( |
435
|
|
|
new XmlResultPrinter( |
436
|
|
|
$arguments['testdoxXMLFile'] |
437
|
|
|
) |
438
|
|
|
); |
439
|
|
|
} |
440
|
|
|
|
441
|
|
|
if (isset($arguments['teamcityLogfile'])) { |
442
|
|
|
$result->addListener( |
443
|
|
|
new TeamCity($arguments['teamcityLogfile']) |
444
|
|
|
); |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
if (isset($arguments['junitLogfile'])) { |
448
|
|
|
$result->addListener( |
449
|
|
|
new JUnit( |
450
|
|
|
$arguments['junitLogfile'], |
451
|
|
|
$arguments['reportUselessTests'] |
452
|
|
|
) |
453
|
|
|
); |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
if (isset($arguments['coverageClover'])) { |
457
|
|
|
$codeCoverageReports++; |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
if (isset($arguments['coverageCrap4J'])) { |
461
|
|
|
$codeCoverageReports++; |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
if (isset($arguments['coverageHtml'])) { |
465
|
|
|
$codeCoverageReports++; |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
if (isset($arguments['coveragePHP'])) { |
469
|
|
|
$codeCoverageReports++; |
470
|
|
|
} |
471
|
|
|
|
472
|
|
|
if (isset($arguments['coverageText'])) { |
473
|
|
|
$codeCoverageReports++; |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
if (isset($arguments['coverageXml'])) { |
477
|
|
|
$codeCoverageReports++; |
478
|
|
|
} |
479
|
|
|
} |
480
|
|
|
|
481
|
|
|
if (isset($arguments['noCoverage'])) { |
482
|
|
|
$codeCoverageReports = 0; |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
if ($codeCoverageReports > 0 && !$this->runtime->canCollectCodeCoverage()) { |
486
|
|
|
$this->writeMessage('Error', 'No code coverage driver is available'); |
487
|
|
|
|
488
|
|
|
$codeCoverageReports = 0; |
489
|
|
|
} |
490
|
|
|
|
491
|
|
|
if ($codeCoverageReports > 0 || isset($arguments['xdebugFilterFile'])) { |
492
|
|
|
$whitelistFromConfigurationFile = false; |
493
|
|
|
$whitelistFromOption = false; |
494
|
|
|
|
495
|
|
|
if (isset($arguments['whitelist'])) { |
496
|
|
|
$this->codeCoverageFilter->addDirectoryToWhitelist($arguments['whitelist']); |
497
|
|
|
|
498
|
|
|
$whitelistFromOption = true; |
499
|
|
|
} |
500
|
|
|
|
501
|
|
|
if (isset($arguments['configuration'])) { |
502
|
|
|
$filterConfiguration = $arguments['configuration']->getFilterConfiguration(); |
503
|
|
|
|
504
|
|
|
if (!empty($filterConfiguration['whitelist'])) { |
505
|
|
|
$whitelistFromConfigurationFile = true; |
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
if (!empty($filterConfiguration['whitelist'])) { |
509
|
|
|
foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) { |
510
|
|
|
$this->codeCoverageFilter->addDirectoryToWhitelist( |
511
|
|
|
$dir['path'], |
512
|
|
|
$dir['suffix'], |
513
|
|
|
$dir['prefix'] |
514
|
|
|
); |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
foreach ($filterConfiguration['whitelist']['include']['file'] as $file) { |
518
|
|
|
$this->codeCoverageFilter->addFileToWhitelist($file); |
519
|
|
|
} |
520
|
|
|
|
521
|
|
|
foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) { |
522
|
|
|
$this->codeCoverageFilter->removeDirectoryFromWhitelist( |
523
|
|
|
$dir['path'], |
524
|
|
|
$dir['suffix'], |
525
|
|
|
$dir['prefix'] |
526
|
|
|
); |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) { |
530
|
|
|
$this->codeCoverageFilter->removeFileFromWhitelist($file); |
531
|
|
|
} |
532
|
|
|
} |
533
|
|
|
} |
534
|
|
|
} |
535
|
|
|
|
536
|
|
|
if ($codeCoverageReports > 0) { |
537
|
|
|
$codeCoverage = new CodeCoverage( |
538
|
|
|
null, |
539
|
|
|
$this->codeCoverageFilter |
540
|
|
|
); |
541
|
|
|
|
542
|
|
|
$codeCoverage->setUnintentionallyCoveredSubclassesWhitelist( |
543
|
|
|
[Comparator::class] |
544
|
|
|
); |
545
|
|
|
|
546
|
|
|
$codeCoverage->setCheckForUnintentionallyCoveredCode( |
547
|
|
|
$arguments['strictCoverage'] |
548
|
|
|
); |
549
|
|
|
|
550
|
|
|
$codeCoverage->setCheckForMissingCoversAnnotation( |
551
|
|
|
$arguments['strictCoverage'] |
552
|
|
|
); |
553
|
|
|
|
554
|
|
|
if (isset($arguments['forceCoversAnnotation'])) { |
555
|
|
|
$codeCoverage->setForceCoversAnnotation( |
556
|
|
|
$arguments['forceCoversAnnotation'] |
557
|
|
|
); |
558
|
|
|
} |
559
|
|
|
|
560
|
|
|
if (isset($arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'])) { |
561
|
|
|
$codeCoverage->setIgnoreDeprecatedCode( |
562
|
|
|
$arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'] |
563
|
|
|
); |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
if (isset($arguments['disableCodeCoverageIgnore'])) { |
567
|
|
|
$codeCoverage->setDisableIgnoredLines(true); |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
if (!empty($filterConfiguration['whitelist'])) { |
571
|
|
|
$codeCoverage->setAddUncoveredFilesFromWhitelist( |
572
|
|
|
$filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist'] |
573
|
|
|
); |
574
|
|
|
|
575
|
|
|
$codeCoverage->setProcessUncoveredFilesFromWhitelist( |
576
|
|
|
$filterConfiguration['whitelist']['processUncoveredFilesFromWhitelist'] |
577
|
|
|
); |
578
|
|
|
} |
579
|
|
|
|
580
|
|
|
if (!$this->codeCoverageFilter->hasWhitelist()) { |
581
|
|
|
if (!$whitelistFromConfigurationFile && !$whitelistFromOption) { |
|
|
|
|
582
|
|
|
$this->writeMessage('Error', 'No whitelist is configured, no code coverage will be generated.'); |
583
|
|
|
} else { |
584
|
|
|
$this->writeMessage('Error', 'Incorrect whitelist config, no code coverage will be generated.'); |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
$codeCoverageReports = 0; |
588
|
|
|
|
589
|
|
|
unset($codeCoverage); |
590
|
|
|
} |
591
|
|
|
} |
592
|
|
|
|
593
|
|
|
if (isset($arguments['xdebugFilterFile'], $filterConfiguration)) { |
594
|
|
|
$this->write("\n"); |
595
|
|
|
|
596
|
|
|
$script = (new XdebugFilterScriptGenerator)->generate($filterConfiguration['whitelist']); |
597
|
|
|
|
598
|
|
|
if ($arguments['xdebugFilterFile'] !== 'php://stdout' && $arguments['xdebugFilterFile'] !== 'php://stderr' && !Filesystem::createDirectory(\dirname($arguments['xdebugFilterFile']))) { |
599
|
|
|
$this->write(\sprintf('Cannot write Xdebug filter script to %s ' . \PHP_EOL, $arguments['xdebugFilterFile'])); |
600
|
|
|
|
601
|
|
|
exit(self::EXCEPTION_EXIT); |
|
|
|
|
602
|
|
|
} |
603
|
|
|
|
604
|
|
|
\file_put_contents($arguments['xdebugFilterFile'], $script); |
605
|
|
|
|
606
|
|
|
$this->write(\sprintf('Wrote Xdebug filter script to %s ' . \PHP_EOL, $arguments['xdebugFilterFile'])); |
607
|
|
|
|
608
|
|
|
exit(self::SUCCESS_EXIT); |
|
|
|
|
609
|
|
|
} |
610
|
|
|
|
611
|
|
|
$this->printer->write("\n"); |
612
|
|
|
|
613
|
|
|
if (isset($codeCoverage)) { |
614
|
|
|
$result->setCodeCoverage($codeCoverage); |
615
|
|
|
|
616
|
|
|
if ($codeCoverageReports > 1 && isset($arguments['cacheTokens'])) { |
617
|
|
|
$codeCoverage->setCacheTokens($arguments['cacheTokens']); |
618
|
|
|
} |
619
|
|
|
} |
620
|
|
|
|
621
|
|
|
$result->beStrictAboutTestsThatDoNotTestAnything($arguments['reportUselessTests']); |
622
|
|
|
$result->beStrictAboutOutputDuringTests($arguments['disallowTestOutput']); |
623
|
|
|
$result->beStrictAboutTodoAnnotatedTests($arguments['disallowTodoAnnotatedTests']); |
624
|
|
|
$result->beStrictAboutResourceUsageDuringSmallTests($arguments['beStrictAboutResourceUsageDuringSmallTests']); |
625
|
|
|
|
626
|
|
|
if ($arguments['enforceTimeLimit'] === true) { |
627
|
|
|
if (!\class_exists(Invoker::class)) { |
628
|
|
|
$this->writeMessage('Error', 'Package phpunit/php-invoker is required for enforcing time limits'); |
629
|
|
|
} |
630
|
|
|
|
631
|
|
|
if (!\extension_loaded('pcntl') || \strpos(\ini_get('disable_functions'), 'pcntl') !== false) { |
632
|
|
|
$this->writeMessage('Error', 'PHP extension pcntl is required for enforcing time limits'); |
633
|
|
|
} |
634
|
|
|
} |
635
|
|
|
$result->enforceTimeLimit($arguments['enforceTimeLimit']); |
636
|
|
|
$result->setDefaultTimeLimit($arguments['defaultTimeLimit']); |
637
|
|
|
$result->setTimeoutForSmallTests($arguments['timeoutForSmallTests']); |
638
|
|
|
$result->setTimeoutForMediumTests($arguments['timeoutForMediumTests']); |
639
|
|
|
$result->setTimeoutForLargeTests($arguments['timeoutForLargeTests']); |
640
|
|
|
|
641
|
|
|
if ($suite instanceof TestSuite) { |
642
|
|
|
$this->processSuiteFilters($suite, $arguments); |
643
|
|
|
$suite->setRunTestInSeparateProcess($arguments['processIsolation']); |
644
|
|
|
} |
645
|
|
|
|
646
|
|
|
foreach ($this->extensions as $extension) { |
647
|
|
|
if ($extension instanceof BeforeFirstTestHook) { |
648
|
|
|
$extension->executeBeforeFirstTest(); |
649
|
|
|
} |
650
|
|
|
} |
651
|
|
|
|
652
|
|
|
$suite->run($result); |
653
|
|
|
|
654
|
|
|
foreach ($this->extensions as $extension) { |
655
|
|
|
if ($extension instanceof AfterLastTestHook) { |
656
|
|
|
$extension->executeAfterLastTest(); |
657
|
|
|
} |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
$result->flushListeners(); |
661
|
|
|
|
662
|
|
|
if ($this->printer instanceof ResultPrinter) { |
663
|
|
|
$this->printer->printResult($result); |
664
|
|
|
} |
665
|
|
|
|
666
|
|
|
if (isset($codeCoverage)) { |
667
|
|
|
if (isset($arguments['coverageClover'])) { |
668
|
|
|
$this->printer->write( |
669
|
|
|
"\nGenerating code coverage report in Clover XML format ..." |
670
|
|
|
); |
671
|
|
|
|
672
|
|
|
try { |
673
|
|
|
$writer = new CloverReport; |
674
|
|
|
$writer->process($codeCoverage, $arguments['coverageClover']); |
675
|
|
|
|
676
|
|
|
$this->printer->write(" done\n"); |
677
|
|
|
unset($writer); |
678
|
|
|
} catch (CodeCoverageException $e) { |
679
|
|
|
$this->printer->write( |
680
|
|
|
" failed\n" . $e->getMessage() . "\n" |
681
|
|
|
); |
682
|
|
|
} |
683
|
|
|
} |
684
|
|
|
|
685
|
|
|
if (isset($arguments['coverageCrap4J'])) { |
686
|
|
|
$this->printer->write( |
687
|
|
|
"\nGenerating Crap4J report XML file ..." |
688
|
|
|
); |
689
|
|
|
|
690
|
|
|
try { |
691
|
|
|
$writer = new Crap4jReport($arguments['crap4jThreshold']); |
692
|
|
|
$writer->process($codeCoverage, $arguments['coverageCrap4J']); |
693
|
|
|
|
694
|
|
|
$this->printer->write(" done\n"); |
695
|
|
|
unset($writer); |
696
|
|
|
} catch (CodeCoverageException $e) { |
697
|
|
|
$this->printer->write( |
698
|
|
|
" failed\n" . $e->getMessage() . "\n" |
699
|
|
|
); |
700
|
|
|
} |
701
|
|
|
} |
702
|
|
|
|
703
|
|
|
if (isset($arguments['coverageHtml'])) { |
704
|
|
|
$this->printer->write( |
705
|
|
|
"\nGenerating code coverage report in HTML format ..." |
706
|
|
|
); |
707
|
|
|
|
708
|
|
|
try { |
709
|
|
|
$writer = new HtmlReport( |
710
|
|
|
$arguments['reportLowUpperBound'], |
711
|
|
|
$arguments['reportHighLowerBound'], |
712
|
|
|
\sprintf( |
713
|
|
|
' and <a href="https://phpunit.de/">PHPUnit %s</a>', |
714
|
|
|
Version::id() |
715
|
|
|
) |
716
|
|
|
); |
717
|
|
|
|
718
|
|
|
$writer->process($codeCoverage, $arguments['coverageHtml']); |
719
|
|
|
|
720
|
|
|
$this->printer->write(" done\n"); |
721
|
|
|
unset($writer); |
722
|
|
|
} catch (CodeCoverageException $e) { |
723
|
|
|
$this->printer->write( |
724
|
|
|
" failed\n" . $e->getMessage() . "\n" |
725
|
|
|
); |
726
|
|
|
} |
727
|
|
|
} |
728
|
|
|
|
729
|
|
|
if (isset($arguments['coveragePHP'])) { |
730
|
|
|
$this->printer->write( |
731
|
|
|
"\nGenerating code coverage report in PHP format ..." |
732
|
|
|
); |
733
|
|
|
|
734
|
|
|
try { |
735
|
|
|
$writer = new PhpReport; |
736
|
|
|
$writer->process($codeCoverage, $arguments['coveragePHP']); |
737
|
|
|
|
738
|
|
|
$this->printer->write(" done\n"); |
739
|
|
|
unset($writer); |
740
|
|
|
} catch (CodeCoverageException $e) { |
741
|
|
|
$this->printer->write( |
742
|
|
|
" failed\n" . $e->getMessage() . "\n" |
743
|
|
|
); |
744
|
|
|
} |
745
|
|
|
} |
746
|
|
|
|
747
|
|
|
if (isset($arguments['coverageText'])) { |
748
|
|
|
if ($arguments['coverageText'] == 'php://stdout') { |
749
|
|
|
$outputStream = $this->printer; |
750
|
|
|
$colors = $arguments['colors'] && $arguments['colors'] != ResultPrinter::COLOR_NEVER; |
751
|
|
|
} else { |
752
|
|
|
$outputStream = new Printer($arguments['coverageText']); |
753
|
|
|
$colors = false; |
754
|
|
|
} |
755
|
|
|
|
756
|
|
|
$processor = new TextReport( |
757
|
|
|
$arguments['reportLowUpperBound'], |
758
|
|
|
$arguments['reportHighLowerBound'], |
759
|
|
|
$arguments['coverageTextShowUncoveredFiles'], |
760
|
|
|
$arguments['coverageTextShowOnlySummary'] |
761
|
|
|
); |
762
|
|
|
|
763
|
|
|
$outputStream->write( |
764
|
|
|
$processor->process($codeCoverage, $colors) |
765
|
|
|
); |
766
|
|
|
} |
767
|
|
|
|
768
|
|
|
if (isset($arguments['coverageXml'])) { |
769
|
|
|
$this->printer->write( |
770
|
|
|
"\nGenerating code coverage report in PHPUnit XML format ..." |
771
|
|
|
); |
772
|
|
|
|
773
|
|
|
try { |
774
|
|
|
$writer = new XmlReport(Version::id()); |
775
|
|
|
$writer->process($codeCoverage, $arguments['coverageXml']); |
776
|
|
|
|
777
|
|
|
$this->printer->write(" done\n"); |
778
|
|
|
unset($writer); |
779
|
|
|
} catch (CodeCoverageException $e) { |
780
|
|
|
$this->printer->write( |
781
|
|
|
" failed\n" . $e->getMessage() . "\n" |
782
|
|
|
); |
783
|
|
|
} |
784
|
|
|
} |
785
|
|
|
} |
786
|
|
|
|
787
|
|
|
if ($exit) { |
788
|
|
|
if ($result->wasSuccessfulIgnoringWarnings()) { |
789
|
|
|
if ($arguments['failOnRisky'] && !$result->allHarmless()) { |
790
|
|
|
exit(self::FAILURE_EXIT); |
|
|
|
|
791
|
|
|
} |
792
|
|
|
|
793
|
|
|
if ($arguments['failOnWarning'] && $result->warningCount() > 0) { |
794
|
|
|
exit(self::FAILURE_EXIT); |
|
|
|
|
795
|
|
|
} |
796
|
|
|
|
797
|
|
|
exit(self::SUCCESS_EXIT); |
|
|
|
|
798
|
|
|
} |
799
|
|
|
|
800
|
|
|
if ($result->errorCount() > 0) { |
801
|
|
|
exit(self::EXCEPTION_EXIT); |
|
|
|
|
802
|
|
|
} |
803
|
|
|
|
804
|
|
|
if ($result->failureCount() > 0) { |
805
|
|
|
exit(self::FAILURE_EXIT); |
|
|
|
|
806
|
|
|
} |
807
|
|
|
} |
808
|
|
|
|
809
|
|
|
return $result; |
810
|
|
|
} |
811
|
|
|
|
812
|
|
|
public function setPrinter(ResultPrinter $resultPrinter): void |
813
|
|
|
{ |
814
|
|
|
$this->printer = $resultPrinter; |
815
|
|
|
} |
816
|
|
|
|
817
|
|
|
/** |
818
|
|
|
* Returns the loader to be used. |
819
|
|
|
*/ |
820
|
|
|
public function getLoader(): TestSuiteLoader |
821
|
|
|
{ |
822
|
|
|
if ($this->loader === null) { |
823
|
|
|
$this->loader = new StandardTestSuiteLoader; |
824
|
|
|
} |
825
|
|
|
|
826
|
|
|
return $this->loader; |
827
|
|
|
} |
828
|
|
|
|
829
|
|
|
protected function createTestResult(): TestResult |
830
|
|
|
{ |
831
|
|
|
return new TestResult; |
832
|
|
|
} |
833
|
|
|
|
834
|
|
|
/** |
835
|
|
|
* Override to define how to handle a failed loading of |
836
|
|
|
* a test suite. |
837
|
|
|
*/ |
838
|
|
|
protected function runFailed(string $message): void |
839
|
|
|
{ |
840
|
|
|
$this->write($message . \PHP_EOL); |
841
|
|
|
|
842
|
|
|
exit(self::FAILURE_EXIT); |
|
|
|
|
843
|
|
|
} |
844
|
|
|
|
845
|
|
|
protected function write(string $buffer): void |
846
|
|
|
{ |
847
|
|
|
if (\PHP_SAPI != 'cli' && \PHP_SAPI != 'phpdbg') { |
848
|
|
|
$buffer = \htmlspecialchars($buffer); |
849
|
|
|
} |
850
|
|
|
|
851
|
|
|
if ($this->printer !== null) { |
852
|
|
|
$this->printer->write($buffer); |
853
|
|
|
} else { |
854
|
|
|
print $buffer; |
855
|
|
|
} |
856
|
|
|
} |
857
|
|
|
|
858
|
|
|
/** |
859
|
|
|
* @throws Exception |
860
|
|
|
*/ |
861
|
|
|
protected function handleConfiguration(array &$arguments): void |
862
|
|
|
{ |
863
|
|
|
if (isset($arguments['configuration']) && |
864
|
|
|
!$arguments['configuration'] instanceof Configuration) { |
865
|
|
|
$arguments['configuration'] = Configuration::getInstance( |
866
|
|
|
$arguments['configuration'] |
867
|
|
|
); |
868
|
|
|
} |
869
|
|
|
|
870
|
|
|
$arguments['debug'] = $arguments['debug'] ?? false; |
871
|
|
|
$arguments['filter'] = $arguments['filter'] ?? false; |
872
|
|
|
$arguments['listeners'] = $arguments['listeners'] ?? []; |
873
|
|
|
|
874
|
|
|
if (isset($arguments['configuration'])) { |
875
|
|
|
$arguments['configuration']->handlePHPConfiguration(); |
876
|
|
|
|
877
|
|
|
$phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration(); |
878
|
|
|
|
879
|
|
|
if (isset($phpunitConfiguration['backupGlobals']) && !isset($arguments['backupGlobals'])) { |
880
|
|
|
$arguments['backupGlobals'] = $phpunitConfiguration['backupGlobals']; |
881
|
|
|
} |
882
|
|
|
|
883
|
|
|
if (isset($phpunitConfiguration['backupStaticAttributes']) && !isset($arguments['backupStaticAttributes'])) { |
884
|
|
|
$arguments['backupStaticAttributes'] = $phpunitConfiguration['backupStaticAttributes']; |
885
|
|
|
} |
886
|
|
|
|
887
|
|
|
if (isset($phpunitConfiguration['beStrictAboutChangesToGlobalState']) && !isset($arguments['beStrictAboutChangesToGlobalState'])) { |
888
|
|
|
$arguments['beStrictAboutChangesToGlobalState'] = $phpunitConfiguration['beStrictAboutChangesToGlobalState']; |
889
|
|
|
} |
890
|
|
|
|
891
|
|
|
if (isset($phpunitConfiguration['bootstrap']) && !isset($arguments['bootstrap'])) { |
892
|
|
|
$arguments['bootstrap'] = $phpunitConfiguration['bootstrap']; |
893
|
|
|
} |
894
|
|
|
|
895
|
|
|
if (isset($phpunitConfiguration['cacheResult']) && !isset($arguments['cacheResult'])) { |
896
|
|
|
$arguments['cacheResult'] = $phpunitConfiguration['cacheResult']; |
897
|
|
|
} |
898
|
|
|
|
899
|
|
|
if (isset($phpunitConfiguration['cacheResultFile']) && !isset($arguments['cacheResultFile'])) { |
900
|
|
|
$arguments['cacheResultFile'] = $phpunitConfiguration['cacheResultFile']; |
901
|
|
|
} |
902
|
|
|
|
903
|
|
|
if (isset($phpunitConfiguration['cacheTokens']) && !isset($arguments['cacheTokens'])) { |
904
|
|
|
$arguments['cacheTokens'] = $phpunitConfiguration['cacheTokens']; |
905
|
|
|
} |
906
|
|
|
|
907
|
|
|
if (isset($phpunitConfiguration['cacheTokens']) && !isset($arguments['cacheTokens'])) { |
908
|
|
|
$arguments['cacheTokens'] = $phpunitConfiguration['cacheTokens']; |
909
|
|
|
} |
910
|
|
|
|
911
|
|
|
if (isset($phpunitConfiguration['colors']) && !isset($arguments['colors'])) { |
912
|
|
|
$arguments['colors'] = $phpunitConfiguration['colors']; |
913
|
|
|
} |
914
|
|
|
|
915
|
|
|
if (isset($phpunitConfiguration['convertDeprecationsToExceptions']) && !isset($arguments['convertDeprecationsToExceptions'])) { |
916
|
|
|
$arguments['convertDeprecationsToExceptions'] = $phpunitConfiguration['convertDeprecationsToExceptions']; |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
if (isset($phpunitConfiguration['convertErrorsToExceptions']) && !isset($arguments['convertErrorsToExceptions'])) { |
920
|
|
|
$arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions']; |
921
|
|
|
} |
922
|
|
|
|
923
|
|
|
if (isset($phpunitConfiguration['convertNoticesToExceptions']) && !isset($arguments['convertNoticesToExceptions'])) { |
924
|
|
|
$arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions']; |
925
|
|
|
} |
926
|
|
|
|
927
|
|
|
if (isset($phpunitConfiguration['convertWarningsToExceptions']) && !isset($arguments['convertWarningsToExceptions'])) { |
928
|
|
|
$arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions']; |
929
|
|
|
} |
930
|
|
|
|
931
|
|
|
if (isset($phpunitConfiguration['processIsolation']) && !isset($arguments['processIsolation'])) { |
932
|
|
|
$arguments['processIsolation'] = $phpunitConfiguration['processIsolation']; |
933
|
|
|
} |
934
|
|
|
|
935
|
|
|
if (isset($phpunitConfiguration['stopOnDefect']) && !isset($arguments['stopOnDefect'])) { |
936
|
|
|
$arguments['stopOnDefect'] = $phpunitConfiguration['stopOnDefect']; |
937
|
|
|
} |
938
|
|
|
|
939
|
|
|
if (isset($phpunitConfiguration['stopOnError']) && !isset($arguments['stopOnError'])) { |
940
|
|
|
$arguments['stopOnError'] = $phpunitConfiguration['stopOnError']; |
941
|
|
|
} |
942
|
|
|
|
943
|
|
|
if (isset($phpunitConfiguration['stopOnFailure']) && !isset($arguments['stopOnFailure'])) { |
944
|
|
|
$arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure']; |
945
|
|
|
} |
946
|
|
|
|
947
|
|
|
if (isset($phpunitConfiguration['stopOnWarning']) && !isset($arguments['stopOnWarning'])) { |
948
|
|
|
$arguments['stopOnWarning'] = $phpunitConfiguration['stopOnWarning']; |
949
|
|
|
} |
950
|
|
|
|
951
|
|
|
if (isset($phpunitConfiguration['stopOnIncomplete']) && !isset($arguments['stopOnIncomplete'])) { |
952
|
|
|
$arguments['stopOnIncomplete'] = $phpunitConfiguration['stopOnIncomplete']; |
953
|
|
|
} |
954
|
|
|
|
955
|
|
|
if (isset($phpunitConfiguration['stopOnRisky']) && !isset($arguments['stopOnRisky'])) { |
956
|
|
|
$arguments['stopOnRisky'] = $phpunitConfiguration['stopOnRisky']; |
957
|
|
|
} |
958
|
|
|
|
959
|
|
|
if (isset($phpunitConfiguration['stopOnSkipped']) && !isset($arguments['stopOnSkipped'])) { |
960
|
|
|
$arguments['stopOnSkipped'] = $phpunitConfiguration['stopOnSkipped']; |
961
|
|
|
} |
962
|
|
|
|
963
|
|
|
if (isset($phpunitConfiguration['failOnWarning']) && !isset($arguments['failOnWarning'])) { |
964
|
|
|
$arguments['failOnWarning'] = $phpunitConfiguration['failOnWarning']; |
965
|
|
|
} |
966
|
|
|
|
967
|
|
|
if (isset($phpunitConfiguration['failOnRisky']) && !isset($arguments['failOnRisky'])) { |
968
|
|
|
$arguments['failOnRisky'] = $phpunitConfiguration['failOnRisky']; |
969
|
|
|
} |
970
|
|
|
|
971
|
|
|
if (isset($phpunitConfiguration['timeoutForSmallTests']) && !isset($arguments['timeoutForSmallTests'])) { |
972
|
|
|
$arguments['timeoutForSmallTests'] = $phpunitConfiguration['timeoutForSmallTests']; |
973
|
|
|
} |
974
|
|
|
|
975
|
|
|
if (isset($phpunitConfiguration['timeoutForMediumTests']) && !isset($arguments['timeoutForMediumTests'])) { |
976
|
|
|
$arguments['timeoutForMediumTests'] = $phpunitConfiguration['timeoutForMediumTests']; |
977
|
|
|
} |
978
|
|
|
|
979
|
|
|
if (isset($phpunitConfiguration['timeoutForLargeTests']) && !isset($arguments['timeoutForLargeTests'])) { |
980
|
|
|
$arguments['timeoutForLargeTests'] = $phpunitConfiguration['timeoutForLargeTests']; |
981
|
|
|
} |
982
|
|
|
|
983
|
|
|
if (isset($phpunitConfiguration['reportUselessTests']) && !isset($arguments['reportUselessTests'])) { |
984
|
|
|
$arguments['reportUselessTests'] = $phpunitConfiguration['reportUselessTests']; |
985
|
|
|
} |
986
|
|
|
|
987
|
|
|
if (isset($phpunitConfiguration['strictCoverage']) && !isset($arguments['strictCoverage'])) { |
988
|
|
|
$arguments['strictCoverage'] = $phpunitConfiguration['strictCoverage']; |
989
|
|
|
} |
990
|
|
|
|
991
|
|
|
if (isset($phpunitConfiguration['ignoreDeprecatedCodeUnitsFromCodeCoverage']) && !isset($arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'])) { |
992
|
|
|
$arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'] = $phpunitConfiguration['ignoreDeprecatedCodeUnitsFromCodeCoverage']; |
993
|
|
|
} |
994
|
|
|
|
995
|
|
|
if (isset($phpunitConfiguration['disallowTestOutput']) && !isset($arguments['disallowTestOutput'])) { |
996
|
|
|
$arguments['disallowTestOutput'] = $phpunitConfiguration['disallowTestOutput']; |
997
|
|
|
} |
998
|
|
|
|
999
|
|
|
if (isset($phpunitConfiguration['defaultTimeLimit']) && !isset($arguments['defaultTimeLimit'])) { |
1000
|
|
|
$arguments['defaultTimeLimit'] = $phpunitConfiguration['defaultTimeLimit']; |
1001
|
|
|
} |
1002
|
|
|
|
1003
|
|
|
if (isset($phpunitConfiguration['enforceTimeLimit']) && !isset($arguments['enforceTimeLimit'])) { |
1004
|
|
|
$arguments['enforceTimeLimit'] = $phpunitConfiguration['enforceTimeLimit']; |
1005
|
|
|
} |
1006
|
|
|
|
1007
|
|
|
if (isset($phpunitConfiguration['disallowTodoAnnotatedTests']) && !isset($arguments['disallowTodoAnnotatedTests'])) { |
1008
|
|
|
$arguments['disallowTodoAnnotatedTests'] = $phpunitConfiguration['disallowTodoAnnotatedTests']; |
1009
|
|
|
} |
1010
|
|
|
|
1011
|
|
|
if (isset($phpunitConfiguration['beStrictAboutResourceUsageDuringSmallTests']) && !isset($arguments['beStrictAboutResourceUsageDuringSmallTests'])) { |
1012
|
|
|
$arguments['beStrictAboutResourceUsageDuringSmallTests'] = $phpunitConfiguration['beStrictAboutResourceUsageDuringSmallTests']; |
1013
|
|
|
} |
1014
|
|
|
|
1015
|
|
|
if (isset($phpunitConfiguration['verbose']) && !isset($arguments['verbose'])) { |
1016
|
|
|
$arguments['verbose'] = $phpunitConfiguration['verbose']; |
1017
|
|
|
} |
1018
|
|
|
|
1019
|
|
|
if (isset($phpunitConfiguration['reverseDefectList']) && !isset($arguments['reverseList'])) { |
1020
|
|
|
$arguments['reverseList'] = $phpunitConfiguration['reverseDefectList']; |
1021
|
|
|
} |
1022
|
|
|
|
1023
|
|
|
if (isset($phpunitConfiguration['forceCoversAnnotation']) && !isset($arguments['forceCoversAnnotation'])) { |
1024
|
|
|
$arguments['forceCoversAnnotation'] = $phpunitConfiguration['forceCoversAnnotation']; |
1025
|
|
|
} |
1026
|
|
|
|
1027
|
|
|
if (isset($phpunitConfiguration['disableCodeCoverageIgnore']) && !isset($arguments['disableCodeCoverageIgnore'])) { |
1028
|
|
|
$arguments['disableCodeCoverageIgnore'] = $phpunitConfiguration['disableCodeCoverageIgnore']; |
1029
|
|
|
} |
1030
|
|
|
|
1031
|
|
|
if (isset($phpunitConfiguration['registerMockObjectsFromTestArgumentsRecursively']) && !isset($arguments['registerMockObjectsFromTestArgumentsRecursively'])) { |
1032
|
|
|
$arguments['registerMockObjectsFromTestArgumentsRecursively'] = $phpunitConfiguration['registerMockObjectsFromTestArgumentsRecursively']; |
1033
|
|
|
} |
1034
|
|
|
|
1035
|
|
|
if (isset($phpunitConfiguration['executionOrder']) && !isset($arguments['executionOrder'])) { |
1036
|
|
|
$arguments['executionOrder'] = $phpunitConfiguration['executionOrder']; |
1037
|
|
|
} |
1038
|
|
|
|
1039
|
|
|
if (isset($phpunitConfiguration['executionOrderDefects']) && !isset($arguments['executionOrderDefects'])) { |
1040
|
|
|
$arguments['executionOrderDefects'] = $phpunitConfiguration['executionOrderDefects']; |
1041
|
|
|
} |
1042
|
|
|
|
1043
|
|
|
if (isset($phpunitConfiguration['resolveDependencies']) && !isset($arguments['resolveDependencies'])) { |
1044
|
|
|
$arguments['resolveDependencies'] = $phpunitConfiguration['resolveDependencies']; |
1045
|
|
|
} |
1046
|
|
|
|
1047
|
|
|
$groupCliArgs = []; |
1048
|
|
|
|
1049
|
|
|
if (!empty($arguments['groups'])) { |
1050
|
|
|
$groupCliArgs = $arguments['groups']; |
1051
|
|
|
} |
1052
|
|
|
|
1053
|
|
|
$groupConfiguration = $arguments['configuration']->getGroupConfiguration(); |
1054
|
|
|
|
1055
|
|
|
if (!empty($groupConfiguration['include']) && !isset($arguments['groups'])) { |
1056
|
|
|
$arguments['groups'] = $groupConfiguration['include']; |
1057
|
|
|
} |
1058
|
|
|
|
1059
|
|
|
if (!empty($groupConfiguration['exclude']) && !isset($arguments['excludeGroups'])) { |
1060
|
|
|
$arguments['excludeGroups'] = \array_diff($groupConfiguration['exclude'], $groupCliArgs); |
1061
|
|
|
} |
1062
|
|
|
|
1063
|
|
|
foreach ($arguments['configuration']->getExtensionConfiguration() as $extension) { |
1064
|
|
|
if (!\class_exists($extension['class'], false) && $extension['file'] !== '') { |
1065
|
|
|
require_once $extension['file']; |
1066
|
|
|
} |
1067
|
|
|
|
1068
|
|
|
if (!\class_exists($extension['class'])) { |
1069
|
|
|
throw new Exception( |
1070
|
|
|
\sprintf( |
1071
|
|
|
'Class "%s" does not exist', |
1072
|
|
|
$extension['class'] |
1073
|
|
|
) |
1074
|
|
|
); |
1075
|
|
|
} |
1076
|
|
|
|
1077
|
|
|
$extensionClass = new ReflectionClass($extension['class']); |
1078
|
|
|
|
1079
|
|
|
if (!$extensionClass->implementsInterface(Hook::class)) { |
1080
|
|
|
throw new Exception( |
1081
|
|
|
\sprintf( |
1082
|
|
|
'Class "%s" does not implement a PHPUnit\Runner\Hook interface', |
1083
|
|
|
$extension['class'] |
1084
|
|
|
) |
1085
|
|
|
); |
1086
|
|
|
} |
1087
|
|
|
|
1088
|
|
|
if (\count($extension['arguments']) == 0) { |
1089
|
|
|
$this->extensions[] = $extensionClass->newInstance(); |
1090
|
|
|
} else { |
1091
|
|
|
$this->extensions[] = $extensionClass->newInstanceArgs( |
1092
|
|
|
$extension['arguments'] |
1093
|
|
|
); |
1094
|
|
|
} |
1095
|
|
|
} |
1096
|
|
|
|
1097
|
|
|
foreach ($arguments['configuration']->getListenerConfiguration() as $listener) { |
1098
|
|
|
if (!\class_exists($listener['class'], false) && |
1099
|
|
|
$listener['file'] !== '') { |
1100
|
|
|
require_once $listener['file']; |
1101
|
|
|
} |
1102
|
|
|
|
1103
|
|
|
if (!\class_exists($listener['class'])) { |
1104
|
|
|
throw new Exception( |
1105
|
|
|
\sprintf( |
1106
|
|
|
'Class "%s" does not exist', |
1107
|
|
|
$listener['class'] |
1108
|
|
|
) |
1109
|
|
|
); |
1110
|
|
|
} |
1111
|
|
|
|
1112
|
|
|
$listenerClass = new ReflectionClass($listener['class']); |
1113
|
|
|
|
1114
|
|
|
if (!$listenerClass->implementsInterface(TestListener::class)) { |
1115
|
|
|
throw new Exception( |
1116
|
|
|
\sprintf( |
1117
|
|
|
'Class "%s" does not implement the PHPUnit\Framework\TestListener interface', |
1118
|
|
|
$listener['class'] |
1119
|
|
|
) |
1120
|
|
|
); |
1121
|
|
|
} |
1122
|
|
|
|
1123
|
|
|
if (\count($listener['arguments']) == 0) { |
1124
|
|
|
$listener = new $listener['class']; |
1125
|
|
|
} else { |
1126
|
|
|
$listener = $listenerClass->newInstanceArgs( |
1127
|
|
|
$listener['arguments'] |
1128
|
|
|
); |
1129
|
|
|
} |
1130
|
|
|
|
1131
|
|
|
$arguments['listeners'][] = $listener; |
1132
|
|
|
} |
1133
|
|
|
|
1134
|
|
|
$loggingConfiguration = $arguments['configuration']->getLoggingConfiguration(); |
1135
|
|
|
|
1136
|
|
|
if (isset($loggingConfiguration['coverage-clover']) && !isset($arguments['coverageClover'])) { |
1137
|
|
|
$arguments['coverageClover'] = $loggingConfiguration['coverage-clover']; |
1138
|
|
|
} |
1139
|
|
|
|
1140
|
|
|
if (isset($loggingConfiguration['coverage-crap4j']) && !isset($arguments['coverageCrap4J'])) { |
1141
|
|
|
$arguments['coverageCrap4J'] = $loggingConfiguration['coverage-crap4j']; |
1142
|
|
|
|
1143
|
|
|
if (isset($loggingConfiguration['crap4jThreshold']) && !isset($arguments['crap4jThreshold'])) { |
1144
|
|
|
$arguments['crap4jThreshold'] = $loggingConfiguration['crap4jThreshold']; |
1145
|
|
|
} |
1146
|
|
|
} |
1147
|
|
|
|
1148
|
|
|
if (isset($loggingConfiguration['coverage-html']) && !isset($arguments['coverageHtml'])) { |
1149
|
|
|
if (isset($loggingConfiguration['lowUpperBound']) && !isset($arguments['reportLowUpperBound'])) { |
1150
|
|
|
$arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound']; |
1151
|
|
|
} |
1152
|
|
|
|
1153
|
|
|
if (isset($loggingConfiguration['highLowerBound']) && !isset($arguments['reportHighLowerBound'])) { |
1154
|
|
|
$arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound']; |
1155
|
|
|
} |
1156
|
|
|
|
1157
|
|
|
$arguments['coverageHtml'] = $loggingConfiguration['coverage-html']; |
1158
|
|
|
} |
1159
|
|
|
|
1160
|
|
|
if (isset($loggingConfiguration['coverage-php']) && !isset($arguments['coveragePHP'])) { |
1161
|
|
|
$arguments['coveragePHP'] = $loggingConfiguration['coverage-php']; |
1162
|
|
|
} |
1163
|
|
|
|
1164
|
|
|
if (isset($loggingConfiguration['coverage-text']) && !isset($arguments['coverageText'])) { |
1165
|
|
|
$arguments['coverageText'] = $loggingConfiguration['coverage-text']; |
1166
|
|
|
|
1167
|
|
|
if (isset($loggingConfiguration['coverageTextShowUncoveredFiles'])) { |
1168
|
|
|
$arguments['coverageTextShowUncoveredFiles'] = $loggingConfiguration['coverageTextShowUncoveredFiles']; |
1169
|
|
|
} else { |
1170
|
|
|
$arguments['coverageTextShowUncoveredFiles'] = false; |
1171
|
|
|
} |
1172
|
|
|
|
1173
|
|
|
if (isset($loggingConfiguration['coverageTextShowOnlySummary'])) { |
1174
|
|
|
$arguments['coverageTextShowOnlySummary'] = $loggingConfiguration['coverageTextShowOnlySummary']; |
1175
|
|
|
} else { |
1176
|
|
|
$arguments['coverageTextShowOnlySummary'] = false; |
1177
|
|
|
} |
1178
|
|
|
} |
1179
|
|
|
|
1180
|
|
|
if (isset($loggingConfiguration['coverage-xml']) && !isset($arguments['coverageXml'])) { |
1181
|
|
|
$arguments['coverageXml'] = $loggingConfiguration['coverage-xml']; |
1182
|
|
|
} |
1183
|
|
|
|
1184
|
|
|
if (isset($loggingConfiguration['plain'])) { |
1185
|
|
|
$arguments['listeners'][] = new ResultPrinter( |
1186
|
|
|
$loggingConfiguration['plain'], |
1187
|
|
|
true |
1188
|
|
|
); |
1189
|
|
|
} |
1190
|
|
|
|
1191
|
|
|
if (isset($loggingConfiguration['teamcity']) && !isset($arguments['teamcityLogfile'])) { |
1192
|
|
|
$arguments['teamcityLogfile'] = $loggingConfiguration['teamcity']; |
1193
|
|
|
} |
1194
|
|
|
|
1195
|
|
|
if (isset($loggingConfiguration['junit']) && !isset($arguments['junitLogfile'])) { |
1196
|
|
|
$arguments['junitLogfile'] = $loggingConfiguration['junit']; |
1197
|
|
|
} |
1198
|
|
|
|
1199
|
|
|
if (isset($loggingConfiguration['testdox-html']) && !isset($arguments['testdoxHTMLFile'])) { |
1200
|
|
|
$arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html']; |
1201
|
|
|
} |
1202
|
|
|
|
1203
|
|
|
if (isset($loggingConfiguration['testdox-text']) && !isset($arguments['testdoxTextFile'])) { |
1204
|
|
|
$arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text']; |
1205
|
|
|
} |
1206
|
|
|
|
1207
|
|
|
if (isset($loggingConfiguration['testdox-xml']) && !isset($arguments['testdoxXMLFile'])) { |
1208
|
|
|
$arguments['testdoxXMLFile'] = $loggingConfiguration['testdox-xml']; |
1209
|
|
|
} |
1210
|
|
|
|
1211
|
|
|
$testdoxGroupConfiguration = $arguments['configuration']->getTestdoxGroupConfiguration(); |
1212
|
|
|
|
1213
|
|
|
if (isset($testdoxGroupConfiguration['include']) && |
1214
|
|
|
!isset($arguments['testdoxGroups'])) { |
1215
|
|
|
$arguments['testdoxGroups'] = $testdoxGroupConfiguration['include']; |
1216
|
|
|
} |
1217
|
|
|
|
1218
|
|
|
if (isset($testdoxGroupConfiguration['exclude']) && |
1219
|
|
|
!isset($arguments['testdoxExcludeGroups'])) { |
1220
|
|
|
$arguments['testdoxExcludeGroups'] = $testdoxGroupConfiguration['exclude']; |
1221
|
|
|
} |
1222
|
|
|
} |
1223
|
|
|
|
1224
|
|
|
$arguments['addUncoveredFilesFromWhitelist'] = $arguments['addUncoveredFilesFromWhitelist'] ?? true; |
1225
|
|
|
$arguments['backupGlobals'] = $arguments['backupGlobals'] ?? null; |
1226
|
|
|
$arguments['backupStaticAttributes'] = $arguments['backupStaticAttributes'] ?? null; |
1227
|
|
|
$arguments['beStrictAboutChangesToGlobalState'] = $arguments['beStrictAboutChangesToGlobalState'] ?? null; |
1228
|
|
|
$arguments['beStrictAboutResourceUsageDuringSmallTests'] = $arguments['beStrictAboutResourceUsageDuringSmallTests'] ?? false; |
1229
|
|
|
$arguments['cacheResult'] = $arguments['cacheResult'] ?? false; |
1230
|
|
|
$arguments['cacheTokens'] = $arguments['cacheTokens'] ?? false; |
1231
|
|
|
$arguments['colors'] = $arguments['colors'] ?? ResultPrinter::COLOR_DEFAULT; |
1232
|
|
|
$arguments['columns'] = $arguments['columns'] ?? 80; |
1233
|
|
|
$arguments['convertDeprecationsToExceptions'] = $arguments['convertDeprecationsToExceptions'] ?? true; |
1234
|
|
|
$arguments['convertErrorsToExceptions'] = $arguments['convertErrorsToExceptions'] ?? true; |
1235
|
|
|
$arguments['convertNoticesToExceptions'] = $arguments['convertNoticesToExceptions'] ?? true; |
1236
|
|
|
$arguments['convertWarningsToExceptions'] = $arguments['convertWarningsToExceptions'] ?? true; |
1237
|
|
|
$arguments['crap4jThreshold'] = $arguments['crap4jThreshold'] ?? 30; |
1238
|
|
|
$arguments['disallowTestOutput'] = $arguments['disallowTestOutput'] ?? false; |
1239
|
|
|
$arguments['disallowTodoAnnotatedTests'] = $arguments['disallowTodoAnnotatedTests'] ?? false; |
1240
|
|
|
$arguments['defaultTimeLimit'] = $arguments['defaultTimeLimit'] ?? 0; |
1241
|
|
|
$arguments['enforceTimeLimit'] = $arguments['enforceTimeLimit'] ?? false; |
1242
|
|
|
$arguments['excludeGroups'] = $arguments['excludeGroups'] ?? []; |
1243
|
|
|
$arguments['failOnRisky'] = $arguments['failOnRisky'] ?? false; |
1244
|
|
|
$arguments['failOnWarning'] = $arguments['failOnWarning'] ?? false; |
1245
|
|
|
$arguments['executionOrderDefects'] = $arguments['executionOrderDefects'] ?? TestSuiteSorter::ORDER_DEFAULT; |
1246
|
|
|
$arguments['groups'] = $arguments['groups'] ?? []; |
1247
|
|
|
$arguments['processIsolation'] = $arguments['processIsolation'] ?? false; |
1248
|
|
|
$arguments['processUncoveredFilesFromWhitelist'] = $arguments['processUncoveredFilesFromWhitelist'] ?? false; |
1249
|
|
|
$arguments['randomOrderSeed'] = $arguments['randomOrderSeed'] ?? \time(); |
1250
|
|
|
$arguments['registerMockObjectsFromTestArgumentsRecursively'] = $arguments['registerMockObjectsFromTestArgumentsRecursively'] ?? false; |
1251
|
|
|
$arguments['repeat'] = $arguments['repeat'] ?? false; |
1252
|
|
|
$arguments['reportHighLowerBound'] = $arguments['reportHighLowerBound'] ?? 90; |
1253
|
|
|
$arguments['reportLowUpperBound'] = $arguments['reportLowUpperBound'] ?? 50; |
1254
|
|
|
$arguments['reportUselessTests'] = $arguments['reportUselessTests'] ?? true; |
1255
|
|
|
$arguments['reverseList'] = $arguments['reverseList'] ?? false; |
1256
|
|
|
$arguments['executionOrder'] = $arguments['executionOrder'] ?? TestSuiteSorter::ORDER_DEFAULT; |
1257
|
|
|
$arguments['resolveDependencies'] = $arguments['resolveDependencies'] ?? false; |
1258
|
|
|
$arguments['stopOnError'] = $arguments['stopOnError'] ?? false; |
1259
|
|
|
$arguments['stopOnFailure'] = $arguments['stopOnFailure'] ?? false; |
1260
|
|
|
$arguments['stopOnIncomplete'] = $arguments['stopOnIncomplete'] ?? false; |
1261
|
|
|
$arguments['stopOnRisky'] = $arguments['stopOnRisky'] ?? false; |
1262
|
|
|
$arguments['stopOnSkipped'] = $arguments['stopOnSkipped'] ?? false; |
1263
|
|
|
$arguments['stopOnWarning'] = $arguments['stopOnWarning'] ?? false; |
1264
|
|
|
$arguments['stopOnDefect'] = $arguments['stopOnDefect'] ?? false; |
1265
|
|
|
$arguments['strictCoverage'] = $arguments['strictCoverage'] ?? false; |
1266
|
|
|
$arguments['testdoxExcludeGroups'] = $arguments['testdoxExcludeGroups'] ?? []; |
1267
|
|
|
$arguments['testdoxGroups'] = $arguments['testdoxGroups'] ?? []; |
1268
|
|
|
$arguments['timeoutForLargeTests'] = $arguments['timeoutForLargeTests'] ?? 60; |
1269
|
|
|
$arguments['timeoutForMediumTests'] = $arguments['timeoutForMediumTests'] ?? 10; |
1270
|
|
|
$arguments['timeoutForSmallTests'] = $arguments['timeoutForSmallTests'] ?? 1; |
1271
|
|
|
$arguments['verbose'] = $arguments['verbose'] ?? false; |
1272
|
|
|
} |
1273
|
|
|
|
1274
|
|
|
/** |
1275
|
|
|
* @throws \ReflectionException |
1276
|
|
|
* @throws \InvalidArgumentException |
1277
|
|
|
*/ |
1278
|
|
|
private function processSuiteFilters(TestSuite $suite, array $arguments): void |
1279
|
|
|
{ |
1280
|
|
|
if (!$arguments['filter'] && |
1281
|
|
|
empty($arguments['groups']) && |
1282
|
|
|
empty($arguments['excludeGroups'])) { |
1283
|
|
|
return; |
1284
|
|
|
} |
1285
|
|
|
|
1286
|
|
|
$filterFactory = new Factory; |
1287
|
|
|
|
1288
|
|
|
if (!empty($arguments['excludeGroups'])) { |
1289
|
|
|
$filterFactory->addFilter( |
1290
|
|
|
new ReflectionClass(ExcludeGroupFilterIterator::class), |
1291
|
|
|
$arguments['excludeGroups'] |
1292
|
|
|
); |
1293
|
|
|
} |
1294
|
|
|
|
1295
|
|
|
if (!empty($arguments['groups'])) { |
1296
|
|
|
$filterFactory->addFilter( |
1297
|
|
|
new ReflectionClass(IncludeGroupFilterIterator::class), |
1298
|
|
|
$arguments['groups'] |
1299
|
|
|
); |
1300
|
|
|
} |
1301
|
|
|
|
1302
|
|
|
if ($arguments['filter']) { |
1303
|
|
|
$filterFactory->addFilter( |
1304
|
|
|
new ReflectionClass(NameFilterIterator::class), |
1305
|
|
|
$arguments['filter'] |
1306
|
|
|
); |
1307
|
|
|
} |
1308
|
|
|
|
1309
|
|
|
$suite->injectFilter($filterFactory); |
1310
|
|
|
} |
1311
|
|
|
|
1312
|
|
|
private function writeMessage(string $type, string $message): void |
1313
|
|
|
{ |
1314
|
|
|
if (!$this->messagePrinted) { |
1315
|
|
|
$this->write("\n"); |
1316
|
|
|
} |
1317
|
|
|
|
1318
|
|
|
$this->write( |
1319
|
|
|
\sprintf( |
1320
|
|
|
"%-15s%s\n", |
1321
|
|
|
$type . ':', |
1322
|
|
|
$message |
1323
|
|
|
) |
1324
|
|
|
); |
1325
|
|
|
|
1326
|
|
|
$this->messagePrinted = true; |
1327
|
|
|
} |
1328
|
|
|
} |
1329
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths