Conditions | 132 |
Total Lines | 655 |
Code Lines | 362 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
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 | } |
||
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