Completed
Push — master ( 52755b...6c4366 )
by smiley
02:13
created
vendor/phpunit/phpunit/src/TextUI/TestRunner.php 1 patch
Indentation   +1050 added lines, -1050 removed lines patch added patch discarded remove patch
@@ -52,1054 +52,1054 @@
 block discarded – undo
52 52
  */
53 53
 class TestRunner extends BaseTestRunner
54 54
 {
55
-    const SUCCESS_EXIT   = 0;
56
-    const FAILURE_EXIT   = 1;
57
-    const EXCEPTION_EXIT = 2;
58
-
59
-    /**
60
-     * @var CodeCoverageFilter
61
-     */
62
-    protected $codeCoverageFilter;
63
-
64
-    /**
65
-     * @var TestSuiteLoader
66
-     */
67
-    protected $loader;
68
-
69
-    /**
70
-     * @var ResultPrinter
71
-     */
72
-    protected $printer;
73
-
74
-    /**
75
-     * @var bool
76
-     */
77
-    protected static $versionStringPrinted = false;
78
-
79
-    /**
80
-     * @var Runtime
81
-     */
82
-    private $runtime;
83
-
84
-    /**
85
-     * @var bool
86
-     */
87
-    private $messagePrinted = false;
88
-
89
-    /**
90
-     * @param TestSuiteLoader    $loader
91
-     * @param CodeCoverageFilter $filter
92
-     */
93
-    public function __construct(TestSuiteLoader $loader = null, CodeCoverageFilter $filter = null)
94
-    {
95
-        if ($filter === null) {
96
-            $filter = new CodeCoverageFilter;
97
-        }
98
-
99
-        $this->codeCoverageFilter = $filter;
100
-        $this->loader             = $loader;
101
-        $this->runtime            = new Runtime;
102
-    }
103
-
104
-    /**
105
-     * @param Test|ReflectionClass $test
106
-     * @param array                $arguments
107
-     *
108
-     * @return TestResult
109
-     *
110
-     * @throws Exception
111
-     */
112
-    public static function run($test, array $arguments = [])
113
-    {
114
-        if ($test instanceof ReflectionClass) {
115
-            $test = new TestSuite($test);
116
-        }
117
-
118
-        if ($test instanceof Test) {
119
-            $aTestRunner = new self;
120
-
121
-            return $aTestRunner->doRun(
122
-                $test,
123
-                $arguments
124
-            );
125
-        }
126
-
127
-        throw new Exception('No test case or test suite found.');
128
-    }
129
-
130
-    /**
131
-     * @return TestResult
132
-     */
133
-    protected function createTestResult()
134
-    {
135
-        return new TestResult;
136
-    }
137
-
138
-    /**
139
-     * @param TestSuite $suite
140
-     * @param array     $arguments
141
-     */
142
-    private function processSuiteFilters(TestSuite $suite, array $arguments)
143
-    {
144
-        if (!$arguments['filter'] &&
145
-            empty($arguments['groups']) &&
146
-            empty($arguments['excludeGroups'])) {
147
-            return;
148
-        }
149
-
150
-        $filterFactory = new Factory;
151
-
152
-        if (!empty($arguments['excludeGroups'])) {
153
-            $filterFactory->addFilter(
154
-                new ReflectionClass(ExcludeGroupFilterIterator::class),
155
-                $arguments['excludeGroups']
156
-            );
157
-        }
158
-
159
-        if (!empty($arguments['groups'])) {
160
-            $filterFactory->addFilter(
161
-                new ReflectionClass(IncludeGroupFilterIterator::class),
162
-                $arguments['groups']
163
-            );
164
-        }
165
-
166
-        if ($arguments['filter']) {
167
-            $filterFactory->addFilter(
168
-                new ReflectionClass(NameFilterIterator::class),
169
-                $arguments['filter']
170
-            );
171
-        }
172
-
173
-        $suite->injectFilter($filterFactory);
174
-    }
175
-
176
-    /**
177
-     * @param Test  $suite
178
-     * @param array $arguments
179
-     * @param bool  $exit
180
-     *
181
-     * @return TestResult
182
-     */
183
-    public function doRun(Test $suite, array $arguments = [], $exit = true)
184
-    {
185
-        if (isset($arguments['configuration'])) {
186
-            $GLOBALS['__PHPUNIT_CONFIGURATION_FILE'] = $arguments['configuration'];
187
-        }
188
-
189
-        $this->handleConfiguration($arguments);
190
-
191
-        $this->processSuiteFilters($suite, $arguments);
192
-
193
-        if (isset($arguments['bootstrap'])) {
194
-            $GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap'];
195
-        }
196
-
197
-        if ($arguments['backupGlobals'] === true) {
198
-            $suite->setBackupGlobals(true);
199
-        }
200
-
201
-        if ($arguments['backupStaticAttributes'] === true) {
202
-            $suite->setBackupStaticAttributes(true);
203
-        }
204
-
205
-        if ($arguments['beStrictAboutChangesToGlobalState'] === true) {
206
-            $suite->setbeStrictAboutChangesToGlobalState(true);
207
-        }
208
-
209
-        if (\is_int($arguments['repeat']) && $arguments['repeat'] > 0) {
210
-            $_suite = new TestSuite;
211
-
212
-            foreach (\range(1, $arguments['repeat']) as $step) {
213
-                $_suite->addTest($suite);
214
-            }
215
-
216
-            $suite = $_suite;
217
-            unset($_suite);
218
-        }
219
-
220
-        $result = $this->createTestResult();
221
-
222
-        if (!$arguments['convertErrorsToExceptions']) {
223
-            $result->convertErrorsToExceptions(false);
224
-        }
225
-
226
-        if (!$arguments['convertDeprecationsToExceptions']) {
227
-            Deprecated::$enabled = false;
228
-        }
229
-
230
-        if (!$arguments['convertNoticesToExceptions']) {
231
-            Notice::$enabled = false;
232
-        }
233
-
234
-        if (!$arguments['convertWarningsToExceptions']) {
235
-            Warning::$enabled = false;
236
-        }
237
-
238
-        if ($arguments['stopOnError']) {
239
-            $result->stopOnError(true);
240
-        }
241
-
242
-        if ($arguments['stopOnFailure']) {
243
-            $result->stopOnFailure(true);
244
-        }
245
-
246
-        if ($arguments['stopOnWarning']) {
247
-            $result->stopOnWarning(true);
248
-        }
249
-
250
-        if ($arguments['stopOnIncomplete']) {
251
-            $result->stopOnIncomplete(true);
252
-        }
253
-
254
-        if ($arguments['stopOnRisky']) {
255
-            $result->stopOnRisky(true);
256
-        }
257
-
258
-        if ($arguments['stopOnSkipped']) {
259
-            $result->stopOnSkipped(true);
260
-        }
261
-
262
-        if ($arguments['registerMockObjectsFromTestArgumentsRecursively']) {
263
-            $result->setRegisterMockObjectsFromTestArgumentsRecursively(true);
264
-        }
265
-
266
-        if ($this->printer === null) {
267
-            if (isset($arguments['printer']) &&
268
-                $arguments['printer'] instanceof Printer) {
269
-                $this->printer = $arguments['printer'];
270
-            } else {
271
-                $printerClass = ResultPrinter::class;
272
-
273
-                if (isset($arguments['printer']) && \is_string($arguments['printer']) && \class_exists($arguments['printer'], false)) {
274
-                    $class = new ReflectionClass($arguments['printer']);
275
-
276
-                    if ($class->isSubclassOf(ResultPrinter::class)) {
277
-                        $printerClass = $arguments['printer'];
278
-                    }
279
-                }
280
-
281
-                $this->printer = new $printerClass(
282
-                    (isset($arguments['stderr']) && $arguments['stderr'] === true) ? 'php://stderr' : null,
283
-                    $arguments['verbose'],
284
-                    $arguments['colors'],
285
-                    $arguments['debug'],
286
-                    $arguments['columns'],
287
-                    $arguments['reverseList']
288
-                );
289
-            }
290
-        }
291
-
292
-        $this->printer->write(
293
-            Version::getVersionString() . "\n"
294
-        );
295
-
296
-        self::$versionStringPrinted = true;
297
-
298
-        if ($arguments['verbose']) {
299
-            $runtime = $this->runtime->getNameWithVersion();
300
-
301
-            if ($this->runtime->hasXdebug()) {
302
-                $runtime .= \sprintf(
303
-                    ' with Xdebug %s',
304
-                    \phpversion('xdebug')
305
-                );
306
-            }
307
-
308
-            $this->writeMessage('Runtime', $runtime);
309
-
310
-            if (isset($arguments['configuration'])) {
311
-                $this->writeMessage(
312
-                    'Configuration',
313
-                    $arguments['configuration']->getFilename()
314
-                );
315
-            }
316
-
317
-            foreach ($arguments['loadedExtensions'] as $extension) {
318
-                $this->writeMessage(
319
-                    'Extension',
320
-                    $extension
321
-                );
322
-            }
323
-
324
-            foreach ($arguments['notLoadedExtensions'] as $extension) {
325
-                $this->writeMessage(
326
-                    'Extension',
327
-                    $extension
328
-                );
329
-            }
330
-        }
331
-
332
-        if ($this->runtime->discardsComments()) {
333
-            $this->writeMessage('Warning', 'opcache.save_comments=0 set; annotations will not work');
334
-        }
335
-
336
-        foreach ($arguments['listeners'] as $listener) {
337
-            $result->addListener($listener);
338
-        }
339
-
340
-        $result->addListener($this->printer);
341
-
342
-        $codeCoverageReports = 0;
343
-
344
-        if (!isset($arguments['noLogging'])) {
345
-            if (isset($arguments['testdoxHTMLFile'])) {
346
-                $result->addListener(
347
-                    new HtmlResultPrinter(
348
-                        $arguments['testdoxHTMLFile'],
349
-                        $arguments['testdoxGroups'],
350
-                        $arguments['testdoxExcludeGroups']
351
-                    )
352
-                );
353
-            }
354
-
355
-            if (isset($arguments['testdoxTextFile'])) {
356
-                $result->addListener(
357
-                    new TextResultPrinter(
358
-                        $arguments['testdoxTextFile'],
359
-                        $arguments['testdoxGroups'],
360
-                        $arguments['testdoxExcludeGroups']
361
-                    )
362
-                );
363
-            }
364
-
365
-            if (isset($arguments['testdoxXMLFile'])) {
366
-                $result->addListener(
367
-                    new XmlResultPrinter(
368
-                        $arguments['testdoxXMLFile']
369
-                    )
370
-                );
371
-            }
372
-
373
-            if (isset($arguments['teamcityLogfile'])) {
374
-                $result->addListener(
375
-                    new TeamCity($arguments['teamcityLogfile'])
376
-                );
377
-            }
378
-
379
-            if (isset($arguments['junitLogfile'])) {
380
-                $result->addListener(
381
-                    new JUnit(
382
-                        $arguments['junitLogfile'],
383
-                        $arguments['reportUselessTests']
384
-                    )
385
-                );
386
-            }
387
-
388
-            if (isset($arguments['coverageClover'])) {
389
-                $codeCoverageReports++;
390
-            }
391
-
392
-            if (isset($arguments['coverageCrap4J'])) {
393
-                $codeCoverageReports++;
394
-            }
395
-
396
-            if (isset($arguments['coverageHtml'])) {
397
-                $codeCoverageReports++;
398
-            }
399
-
400
-            if (isset($arguments['coveragePHP'])) {
401
-                $codeCoverageReports++;
402
-            }
403
-
404
-            if (isset($arguments['coverageText'])) {
405
-                $codeCoverageReports++;
406
-            }
407
-
408
-            if (isset($arguments['coverageXml'])) {
409
-                $codeCoverageReports++;
410
-            }
411
-        }
412
-
413
-        if (isset($arguments['noCoverage'])) {
414
-            $codeCoverageReports = 0;
415
-        }
416
-
417
-        if ($codeCoverageReports > 0 && !$this->runtime->canCollectCodeCoverage()) {
418
-            $this->writeMessage('Error', 'No code coverage driver is available');
419
-
420
-            $codeCoverageReports = 0;
421
-        }
422
-
423
-        if ($codeCoverageReports > 0) {
424
-            $codeCoverage = new CodeCoverage(
425
-                null,
426
-                $this->codeCoverageFilter
427
-            );
428
-
429
-            $codeCoverage->setUnintentionallyCoveredSubclassesWhitelist(
430
-                [SebastianBergmann\Comparator\Comparator::class]
431
-            );
432
-
433
-            $codeCoverage->setCheckForUnintentionallyCoveredCode(
434
-                $arguments['strictCoverage']
435
-            );
436
-
437
-            $codeCoverage->setCheckForMissingCoversAnnotation(
438
-                $arguments['strictCoverage']
439
-            );
440
-
441
-            if (isset($arguments['forceCoversAnnotation'])) {
442
-                $codeCoverage->setForceCoversAnnotation(
443
-                    $arguments['forceCoversAnnotation']
444
-                );
445
-            }
446
-
447
-            if (isset($arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'])) {
448
-                $codeCoverage->setIgnoreDeprecatedCode(
449
-                    $arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage']
450
-                );
451
-            }
452
-
453
-            if (isset($arguments['disableCodeCoverageIgnore'])) {
454
-                $codeCoverage->setDisableIgnoredLines(true);
455
-            }
456
-
457
-            if (isset($arguments['whitelist'])) {
458
-                $this->codeCoverageFilter->addDirectoryToWhitelist($arguments['whitelist']);
459
-            }
460
-
461
-            if (isset($arguments['configuration'])) {
462
-                $filterConfiguration = $arguments['configuration']->getFilterConfiguration();
463
-
464
-                if (empty($filterConfiguration['whitelist']) && !isset($arguments['whitelist'])) {
465
-                    $this->writeMessage('Error', 'No whitelist is configured, no code coverage will be generated.');
466
-
467
-                    $codeCoverageReports = 0;
468
-
469
-                    unset($codeCoverage);
470
-                } else {
471
-                    $codeCoverage->setAddUncoveredFilesFromWhitelist(
472
-                        $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist']
473
-                    );
474
-
475
-                    $codeCoverage->setProcessUncoveredFilesFromWhitelist(
476
-                        $filterConfiguration['whitelist']['processUncoveredFilesFromWhitelist']
477
-                    );
478
-
479
-                    foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
480
-                        $this->codeCoverageFilter->addDirectoryToWhitelist(
481
-                            $dir['path'],
482
-                            $dir['suffix'],
483
-                            $dir['prefix']
484
-                        );
485
-                    }
486
-
487
-                    foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
488
-                        $this->codeCoverageFilter->addFileToWhitelist($file);
489
-                    }
490
-
491
-                    foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
492
-                        $this->codeCoverageFilter->removeDirectoryFromWhitelist(
493
-                            $dir['path'],
494
-                            $dir['suffix'],
495
-                            $dir['prefix']
496
-                        );
497
-                    }
498
-
499
-                    foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
500
-                        $this->codeCoverageFilter->removeFileFromWhitelist($file);
501
-                    }
502
-                }
503
-            }
504
-
505
-            if (isset($codeCoverage) && !$this->codeCoverageFilter->hasWhitelist()) {
506
-                $this->writeMessage('Error', 'Incorrect whitelist config, no code coverage will be generated.');
507
-
508
-                $codeCoverageReports = 0;
509
-
510
-                unset($codeCoverage);
511
-            }
512
-        }
513
-
514
-        $this->printer->write("\n");
515
-
516
-        if (isset($codeCoverage)) {
517
-            $result->setCodeCoverage($codeCoverage);
518
-
519
-            if ($codeCoverageReports > 1 && isset($arguments['cacheTokens'])) {
520
-                $codeCoverage->setCacheTokens($arguments['cacheTokens']);
521
-            }
522
-        }
523
-
524
-        $result->beStrictAboutTestsThatDoNotTestAnything($arguments['reportUselessTests']);
525
-        $result->beStrictAboutOutputDuringTests($arguments['disallowTestOutput']);
526
-        $result->beStrictAboutTodoAnnotatedTests($arguments['disallowTodoAnnotatedTests']);
527
-        $result->beStrictAboutResourceUsageDuringSmallTests($arguments['beStrictAboutResourceUsageDuringSmallTests']);
528
-        $result->enforceTimeLimit($arguments['enforceTimeLimit']);
529
-        $result->setTimeoutForSmallTests($arguments['timeoutForSmallTests']);
530
-        $result->setTimeoutForMediumTests($arguments['timeoutForMediumTests']);
531
-        $result->setTimeoutForLargeTests($arguments['timeoutForLargeTests']);
532
-
533
-        if ($suite instanceof TestSuite) {
534
-            $suite->setRunTestInSeparateProcess($arguments['processIsolation']);
535
-        }
536
-
537
-        $suite->run($result);
538
-
539
-        unset($suite);
540
-        $result->flushListeners();
541
-
542
-        if ($this->printer instanceof ResultPrinter) {
543
-            $this->printer->printResult($result);
544
-        }
545
-
546
-        if (isset($codeCoverage)) {
547
-            if (isset($arguments['coverageClover'])) {
548
-                $this->printer->write(
549
-                    "\nGenerating code coverage report in Clover XML format ..."
550
-                );
551
-
552
-                try {
553
-                    $writer = new CloverReport;
554
-                    $writer->process($codeCoverage, $arguments['coverageClover']);
555
-
556
-                    $this->printer->write(" done\n");
557
-                    unset($writer);
558
-                } catch (CodeCoverageException $e) {
559
-                    $this->printer->write(
560
-                        " failed\n" . $e->getMessage() . "\n"
561
-                    );
562
-                }
563
-            }
564
-
565
-            if (isset($arguments['coverageCrap4J'])) {
566
-                $this->printer->write(
567
-                    "\nGenerating Crap4J report XML file ..."
568
-                );
569
-
570
-                try {
571
-                    $writer = new Crap4jReport($arguments['crap4jThreshold']);
572
-                    $writer->process($codeCoverage, $arguments['coverageCrap4J']);
573
-
574
-                    $this->printer->write(" done\n");
575
-                    unset($writer);
576
-                } catch (CodeCoverageException $e) {
577
-                    $this->printer->write(
578
-                        " failed\n" . $e->getMessage() . "\n"
579
-                    );
580
-                }
581
-            }
582
-
583
-            if (isset($arguments['coverageHtml'])) {
584
-                $this->printer->write(
585
-                    "\nGenerating code coverage report in HTML format ..."
586
-                );
587
-
588
-                try {
589
-                    $writer = new HtmlReport(
590
-                        $arguments['reportLowUpperBound'],
591
-                        $arguments['reportHighLowerBound'],
592
-                        \sprintf(
593
-                            ' and <a href="https://phpunit.de/">PHPUnit %s</a>',
594
-                            Version::id()
595
-                        )
596
-                    );
597
-
598
-                    $writer->process($codeCoverage, $arguments['coverageHtml']);
599
-
600
-                    $this->printer->write(" done\n");
601
-                    unset($writer);
602
-                } catch (CodeCoverageException $e) {
603
-                    $this->printer->write(
604
-                        " failed\n" . $e->getMessage() . "\n"
605
-                    );
606
-                }
607
-            }
608
-
609
-            if (isset($arguments['coveragePHP'])) {
610
-                $this->printer->write(
611
-                    "\nGenerating code coverage report in PHP format ..."
612
-                );
613
-
614
-                try {
615
-                    $writer = new PhpReport;
616
-                    $writer->process($codeCoverage, $arguments['coveragePHP']);
617
-
618
-                    $this->printer->write(" done\n");
619
-                    unset($writer);
620
-                } catch (CodeCoverageException $e) {
621
-                    $this->printer->write(
622
-                        " failed\n" . $e->getMessage() . "\n"
623
-                    );
624
-                }
625
-            }
626
-
627
-            if (isset($arguments['coverageText'])) {
628
-                if ($arguments['coverageText'] == 'php://stdout') {
629
-                    $outputStream = $this->printer;
630
-                    $colors       = $arguments['colors'] && $arguments['colors'] != ResultPrinter::COLOR_NEVER;
631
-                } else {
632
-                    $outputStream = new Printer($arguments['coverageText']);
633
-                    $colors       = false;
634
-                }
635
-
636
-                $processor = new TextReport(
637
-                    $arguments['reportLowUpperBound'],
638
-                    $arguments['reportHighLowerBound'],
639
-                    $arguments['coverageTextShowUncoveredFiles'],
640
-                    $arguments['coverageTextShowOnlySummary']
641
-                );
642
-
643
-                $outputStream->write(
644
-                    $processor->process($codeCoverage, $colors)
645
-                );
646
-            }
647
-
648
-            if (isset($arguments['coverageXml'])) {
649
-                $this->printer->write(
650
-                    "\nGenerating code coverage report in PHPUnit XML format ..."
651
-                );
652
-
653
-                try {
654
-                    $writer = new XmlReport(Version::id());
655
-                    $writer->process($codeCoverage, $arguments['coverageXml']);
656
-
657
-                    $this->printer->write(" done\n");
658
-                    unset($writer);
659
-                } catch (CodeCoverageException $e) {
660
-                    $this->printer->write(
661
-                        " failed\n" . $e->getMessage() . "\n"
662
-                    );
663
-                }
664
-            }
665
-        }
666
-
667
-        if ($exit) {
668
-            if ($result->wasSuccessful()) {
669
-                if ($arguments['failOnRisky'] && !$result->allHarmless()) {
670
-                    exit(self::FAILURE_EXIT);
671
-                }
672
-
673
-                if ($arguments['failOnWarning'] && $result->warningCount() > 0) {
674
-                    exit(self::FAILURE_EXIT);
675
-                }
676
-
677
-                exit(self::SUCCESS_EXIT);
678
-            }
679
-
680
-            if ($result->errorCount() > 0) {
681
-                exit(self::EXCEPTION_EXIT);
682
-            }
683
-
684
-            if ($result->failureCount() > 0) {
685
-                exit(self::FAILURE_EXIT);
686
-            }
687
-        }
688
-
689
-        return $result;
690
-    }
691
-
692
-    /**
693
-     * @param ResultPrinter $resultPrinter
694
-     */
695
-    public function setPrinter(ResultPrinter $resultPrinter)
696
-    {
697
-        $this->printer = $resultPrinter;
698
-    }
699
-
700
-    /**
701
-     * Override to define how to handle a failed loading of
702
-     * a test suite.
703
-     *
704
-     * @param string $message
705
-     */
706
-    protected function runFailed($message)
707
-    {
708
-        $this->write($message . PHP_EOL);
709
-        exit(self::FAILURE_EXIT);
710
-    }
711
-
712
-    /**
713
-     * @param string $buffer
714
-     */
715
-    protected function write($buffer)
716
-    {
717
-        if (PHP_SAPI != 'cli' && PHP_SAPI != 'phpdbg') {
718
-            $buffer = \htmlspecialchars($buffer);
719
-        }
720
-
721
-        if ($this->printer !== null) {
722
-            $this->printer->write($buffer);
723
-        } else {
724
-            print $buffer;
725
-        }
726
-    }
727
-
728
-    /**
729
-     * Returns the loader to be used.
730
-     *
731
-     * @return TestSuiteLoader
732
-     */
733
-    public function getLoader()
734
-    {
735
-        if ($this->loader === null) {
736
-            $this->loader = new StandardTestSuiteLoader;
737
-        }
738
-
739
-        return $this->loader;
740
-    }
741
-
742
-    /**
743
-     * @param array $arguments
744
-     */
745
-    protected function handleConfiguration(array &$arguments)
746
-    {
747
-        if (isset($arguments['configuration']) &&
748
-            !$arguments['configuration'] instanceof Configuration) {
749
-            $arguments['configuration'] = Configuration::getInstance(
750
-                $arguments['configuration']
751
-            );
752
-        }
753
-
754
-        $arguments['debug']     = $arguments['debug'] ?? false;
755
-        $arguments['filter']    = $arguments['filter'] ?? false;
756
-        $arguments['listeners'] = $arguments['listeners'] ?? [];
757
-
758
-        if (isset($arguments['configuration'])) {
759
-            $arguments['configuration']->handlePHPConfiguration();
760
-
761
-            $phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
762
-
763
-            if (isset($phpunitConfiguration['backupGlobals']) && !isset($arguments['backupGlobals'])) {
764
-                $arguments['backupGlobals'] = $phpunitConfiguration['backupGlobals'];
765
-            }
766
-
767
-            if (isset($phpunitConfiguration['backupStaticAttributes']) && !isset($arguments['backupStaticAttributes'])) {
768
-                $arguments['backupStaticAttributes'] = $phpunitConfiguration['backupStaticAttributes'];
769
-            }
770
-
771
-            if (isset($phpunitConfiguration['beStrictAboutChangesToGlobalState']) && !isset($arguments['beStrictAboutChangesToGlobalState'])) {
772
-                $arguments['beStrictAboutChangesToGlobalState'] = $phpunitConfiguration['beStrictAboutChangesToGlobalState'];
773
-            }
774
-
775
-            if (isset($phpunitConfiguration['bootstrap']) && !isset($arguments['bootstrap'])) {
776
-                $arguments['bootstrap'] = $phpunitConfiguration['bootstrap'];
777
-            }
778
-
779
-            if (isset($phpunitConfiguration['cacheTokens']) && !isset($arguments['cacheTokens'])) {
780
-                $arguments['cacheTokens'] = $phpunitConfiguration['cacheTokens'];
781
-            }
782
-
783
-            if (isset($phpunitConfiguration['colors']) && !isset($arguments['colors'])) {
784
-                $arguments['colors'] = $phpunitConfiguration['colors'];
785
-            }
786
-
787
-            if (isset($phpunitConfiguration['convertDeprecationsToExceptions']) && !isset($arguments['convertDeprecationsToExceptions'])) {
788
-                $arguments['convertDeprecationsToExceptions'] = $phpunitConfiguration['convertDeprecationsToExceptions'];
789
-            }
790
-
791
-            if (isset($phpunitConfiguration['convertErrorsToExceptions']) && !isset($arguments['convertErrorsToExceptions'])) {
792
-                $arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions'];
793
-            }
794
-
795
-            if (isset($phpunitConfiguration['convertNoticesToExceptions']) && !isset($arguments['convertNoticesToExceptions'])) {
796
-                $arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions'];
797
-            }
798
-
799
-            if (isset($phpunitConfiguration['convertWarningsToExceptions']) && !isset($arguments['convertWarningsToExceptions'])) {
800
-                $arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions'];
801
-            }
802
-
803
-            if (isset($phpunitConfiguration['processIsolation']) && !isset($arguments['processIsolation'])) {
804
-                $arguments['processIsolation'] = $phpunitConfiguration['processIsolation'];
805
-            }
806
-
807
-            if (isset($phpunitConfiguration['stopOnError']) && !isset($arguments['stopOnError'])) {
808
-                $arguments['stopOnError'] = $phpunitConfiguration['stopOnError'];
809
-            }
810
-
811
-            if (isset($phpunitConfiguration['stopOnFailure']) && !isset($arguments['stopOnFailure'])) {
812
-                $arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
813
-            }
814
-
815
-            if (isset($phpunitConfiguration['stopOnWarning']) && !isset($arguments['stopOnWarning'])) {
816
-                $arguments['stopOnWarning'] = $phpunitConfiguration['stopOnWarning'];
817
-            }
818
-
819
-            if (isset($phpunitConfiguration['stopOnIncomplete']) && !isset($arguments['stopOnIncomplete'])) {
820
-                $arguments['stopOnIncomplete'] = $phpunitConfiguration['stopOnIncomplete'];
821
-            }
822
-
823
-            if (isset($phpunitConfiguration['stopOnRisky']) && !isset($arguments['stopOnRisky'])) {
824
-                $arguments['stopOnRisky'] = $phpunitConfiguration['stopOnRisky'];
825
-            }
826
-
827
-            if (isset($phpunitConfiguration['stopOnSkipped']) && !isset($arguments['stopOnSkipped'])) {
828
-                $arguments['stopOnSkipped'] = $phpunitConfiguration['stopOnSkipped'];
829
-            }
830
-
831
-            if (isset($phpunitConfiguration['failOnWarning']) && !isset($arguments['failOnWarning'])) {
832
-                $arguments['failOnWarning'] = $phpunitConfiguration['failOnWarning'];
833
-            }
834
-
835
-            if (isset($phpunitConfiguration['failOnRisky']) && !isset($arguments['failOnRisky'])) {
836
-                $arguments['failOnRisky'] = $phpunitConfiguration['failOnRisky'];
837
-            }
838
-
839
-            if (isset($phpunitConfiguration['timeoutForSmallTests']) && !isset($arguments['timeoutForSmallTests'])) {
840
-                $arguments['timeoutForSmallTests'] = $phpunitConfiguration['timeoutForSmallTests'];
841
-            }
842
-
843
-            if (isset($phpunitConfiguration['timeoutForMediumTests']) && !isset($arguments['timeoutForMediumTests'])) {
844
-                $arguments['timeoutForMediumTests'] = $phpunitConfiguration['timeoutForMediumTests'];
845
-            }
846
-
847
-            if (isset($phpunitConfiguration['timeoutForLargeTests']) && !isset($arguments['timeoutForLargeTests'])) {
848
-                $arguments['timeoutForLargeTests'] = $phpunitConfiguration['timeoutForLargeTests'];
849
-            }
850
-
851
-            if (isset($phpunitConfiguration['reportUselessTests']) && !isset($arguments['reportUselessTests'])) {
852
-                $arguments['reportUselessTests'] = $phpunitConfiguration['reportUselessTests'];
853
-            }
854
-
855
-            if (isset($phpunitConfiguration['strictCoverage']) && !isset($arguments['strictCoverage'])) {
856
-                $arguments['strictCoverage'] = $phpunitConfiguration['strictCoverage'];
857
-            }
858
-
859
-            if (isset($phpunitConfiguration['ignoreDeprecatedCodeUnitsFromCodeCoverage']) && !isset($arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'])) {
860
-                $arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'] = $phpunitConfiguration['ignoreDeprecatedCodeUnitsFromCodeCoverage'];
861
-            }
862
-
863
-            if (isset($phpunitConfiguration['disallowTestOutput']) && !isset($arguments['disallowTestOutput'])) {
864
-                $arguments['disallowTestOutput'] = $phpunitConfiguration['disallowTestOutput'];
865
-            }
866
-
867
-            if (isset($phpunitConfiguration['enforceTimeLimit']) && !isset($arguments['enforceTimeLimit'])) {
868
-                $arguments['enforceTimeLimit'] = $phpunitConfiguration['enforceTimeLimit'];
869
-            }
870
-
871
-            if (isset($phpunitConfiguration['disallowTodoAnnotatedTests']) && !isset($arguments['disallowTodoAnnotatedTests'])) {
872
-                $arguments['disallowTodoAnnotatedTests'] = $phpunitConfiguration['disallowTodoAnnotatedTests'];
873
-            }
874
-
875
-            if (isset($phpunitConfiguration['beStrictAboutResourceUsageDuringSmallTests']) && !isset($arguments['beStrictAboutResourceUsageDuringSmallTests'])) {
876
-                $arguments['beStrictAboutResourceUsageDuringSmallTests'] = $phpunitConfiguration['beStrictAboutResourceUsageDuringSmallTests'];
877
-            }
878
-
879
-            if (isset($phpunitConfiguration['verbose']) && !isset($arguments['verbose'])) {
880
-                $arguments['verbose'] = $phpunitConfiguration['verbose'];
881
-            }
882
-
883
-            if (isset($phpunitConfiguration['reverseDefectList']) && !isset($arguments['reverseList'])) {
884
-                $arguments['reverseList'] = $phpunitConfiguration['reverseDefectList'];
885
-            }
886
-
887
-            if (isset($phpunitConfiguration['forceCoversAnnotation']) && !isset($arguments['forceCoversAnnotation'])) {
888
-                $arguments['forceCoversAnnotation'] = $phpunitConfiguration['forceCoversAnnotation'];
889
-            }
890
-
891
-            if (isset($phpunitConfiguration['disableCodeCoverageIgnore']) && !isset($arguments['disableCodeCoverageIgnore'])) {
892
-                $arguments['disableCodeCoverageIgnore'] = $phpunitConfiguration['disableCodeCoverageIgnore'];
893
-            }
894
-
895
-            if (isset($phpunitConfiguration['registerMockObjectsFromTestArgumentsRecursively']) && !isset($arguments['registerMockObjectsFromTestArgumentsRecursively'])) {
896
-                $arguments['registerMockObjectsFromTestArgumentsRecursively'] = $phpunitConfiguration['registerMockObjectsFromTestArgumentsRecursively'];
897
-            }
898
-
899
-            $groupCliArgs = [];
900
-
901
-            if (!empty($arguments['groups'])) {
902
-                $groupCliArgs = $arguments['groups'];
903
-            }
904
-
905
-            $groupConfiguration = $arguments['configuration']->getGroupConfiguration();
906
-
907
-            if (!empty($groupConfiguration['include']) && !isset($arguments['groups'])) {
908
-                $arguments['groups'] = $groupConfiguration['include'];
909
-            }
910
-
911
-            if (!empty($groupConfiguration['exclude']) && !isset($arguments['excludeGroups'])) {
912
-                $arguments['excludeGroups'] = \array_diff($groupConfiguration['exclude'], $groupCliArgs);
913
-            }
914
-
915
-            foreach ($arguments['configuration']->getListenerConfiguration() as $listener) {
916
-                if (!\class_exists($listener['class'], false) &&
917
-                    $listener['file'] !== '') {
918
-                    require_once $listener['file'];
919
-                }
920
-
921
-                if (!\class_exists($listener['class'])) {
922
-                    throw new Exception(
923
-                        \sprintf(
924
-                            'Class "%s" does not exist',
925
-                            $listener['class']
926
-                        )
927
-                    );
928
-                }
929
-
930
-                $listenerClass = new ReflectionClass($listener['class']);
931
-
932
-                if (!$listenerClass->implementsInterface(TestListener::class)) {
933
-                    throw new Exception(
934
-                        \sprintf(
935
-                            'Class "%s" does not implement the PHPUnit\Framework\TestListener interface',
936
-                            $listener['class']
937
-                        )
938
-                    );
939
-                }
940
-
941
-                if (\count($listener['arguments']) == 0) {
942
-                    $listener = new $listener['class'];
943
-                } else {
944
-                    $listener = $listenerClass->newInstanceArgs(
945
-                        $listener['arguments']
946
-                    );
947
-                }
948
-
949
-                $arguments['listeners'][] = $listener;
950
-            }
951
-
952
-            $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
953
-
954
-            if (isset($loggingConfiguration['coverage-clover']) && !isset($arguments['coverageClover'])) {
955
-                $arguments['coverageClover'] = $loggingConfiguration['coverage-clover'];
956
-            }
957
-
958
-            if (isset($loggingConfiguration['coverage-crap4j']) && !isset($arguments['coverageCrap4J'])) {
959
-                $arguments['coverageCrap4J'] = $loggingConfiguration['coverage-crap4j'];
960
-
961
-                if (isset($loggingConfiguration['crap4jThreshold']) && !isset($arguments['crap4jThreshold'])) {
962
-                    $arguments['crap4jThreshold'] = $loggingConfiguration['crap4jThreshold'];
963
-                }
964
-            }
965
-
966
-            if (isset($loggingConfiguration['coverage-html']) && !isset($arguments['coverageHtml'])) {
967
-                if (isset($loggingConfiguration['lowUpperBound']) && !isset($arguments['reportLowUpperBound'])) {
968
-                    $arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound'];
969
-                }
970
-
971
-                if (isset($loggingConfiguration['highLowerBound']) && !isset($arguments['reportHighLowerBound'])) {
972
-                    $arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound'];
973
-                }
974
-
975
-                $arguments['coverageHtml'] = $loggingConfiguration['coverage-html'];
976
-            }
977
-
978
-            if (isset($loggingConfiguration['coverage-php']) && !isset($arguments['coveragePHP'])) {
979
-                $arguments['coveragePHP'] = $loggingConfiguration['coverage-php'];
980
-            }
981
-
982
-            if (isset($loggingConfiguration['coverage-text']) && !isset($arguments['coverageText'])) {
983
-                $arguments['coverageText'] = $loggingConfiguration['coverage-text'];
984
-
985
-                if (isset($loggingConfiguration['coverageTextShowUncoveredFiles'])) {
986
-                    $arguments['coverageTextShowUncoveredFiles'] = $loggingConfiguration['coverageTextShowUncoveredFiles'];
987
-                } else {
988
-                    $arguments['coverageTextShowUncoveredFiles'] = false;
989
-                }
990
-
991
-                if (isset($loggingConfiguration['coverageTextShowOnlySummary'])) {
992
-                    $arguments['coverageTextShowOnlySummary'] = $loggingConfiguration['coverageTextShowOnlySummary'];
993
-                } else {
994
-                    $arguments['coverageTextShowOnlySummary'] = false;
995
-                }
996
-            }
997
-
998
-            if (isset($loggingConfiguration['coverage-xml']) && !isset($arguments['coverageXml'])) {
999
-                $arguments['coverageXml'] = $loggingConfiguration['coverage-xml'];
1000
-            }
1001
-
1002
-            if (isset($loggingConfiguration['plain'])) {
1003
-                $arguments['listeners'][] = new ResultPrinter(
1004
-                    $loggingConfiguration['plain'],
1005
-                    true
1006
-                );
1007
-            }
1008
-
1009
-            if (isset($loggingConfiguration['teamcity']) && !isset($arguments['teamcityLogfile'])) {
1010
-                $arguments['teamcityLogfile'] = $loggingConfiguration['teamcity'];
1011
-            }
1012
-
1013
-            if (isset($loggingConfiguration['junit']) && !isset($arguments['junitLogfile'])) {
1014
-                $arguments['junitLogfile'] = $loggingConfiguration['junit'];
1015
-            }
1016
-
1017
-            if (isset($loggingConfiguration['testdox-html']) && !isset($arguments['testdoxHTMLFile'])) {
1018
-                $arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html'];
1019
-            }
1020
-
1021
-            if (isset($loggingConfiguration['testdox-text']) && !isset($arguments['testdoxTextFile'])) {
1022
-                $arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text'];
1023
-            }
1024
-
1025
-            if (isset($loggingConfiguration['testdox-xml']) && !isset($arguments['testdoxXMLFile'])) {
1026
-                $arguments['testdoxXMLFile'] = $loggingConfiguration['testdox-xml'];
1027
-            }
1028
-
1029
-            $testdoxGroupConfiguration = $arguments['configuration']->getTestdoxGroupConfiguration();
1030
-
1031
-            if (isset($testdoxGroupConfiguration['include']) &&
1032
-                !isset($arguments['testdoxGroups'])) {
1033
-                $arguments['testdoxGroups'] = $testdoxGroupConfiguration['include'];
1034
-            }
1035
-
1036
-            if (isset($testdoxGroupConfiguration['exclude']) &&
1037
-                !isset($arguments['testdoxExcludeGroups'])) {
1038
-                $arguments['testdoxExcludeGroups'] = $testdoxGroupConfiguration['exclude'];
1039
-            }
1040
-        }
1041
-
1042
-        $arguments['addUncoveredFilesFromWhitelist']                  = $arguments['addUncoveredFilesFromWhitelist'] ?? true;
1043
-        $arguments['backupGlobals']                                   = $arguments['backupGlobals'] ?? null;
1044
-        $arguments['backupStaticAttributes']                          = $arguments['backupStaticAttributes'] ?? null;
1045
-        $arguments['beStrictAboutChangesToGlobalState']               = $arguments['beStrictAboutChangesToGlobalState'] ?? null;
1046
-        $arguments['beStrictAboutResourceUsageDuringSmallTests']      = $arguments['beStrictAboutResourceUsageDuringSmallTests'] ?? false;
1047
-        $arguments['cacheTokens']                                     = $arguments['cacheTokens'] ?? false;
1048
-        $arguments['colors']                                          = $arguments['colors'] ?? ResultPrinter::COLOR_DEFAULT;
1049
-        $arguments['columns']                                         = $arguments['columns'] ?? 80;
1050
-        $arguments['convertDeprecationsToExceptions']                 = $arguments['convertDeprecationsToExceptions'] ?? true;
1051
-        $arguments['convertErrorsToExceptions']                       = $arguments['convertErrorsToExceptions'] ?? true;
1052
-        $arguments['convertNoticesToExceptions']                      = $arguments['convertNoticesToExceptions'] ?? true;
1053
-        $arguments['convertWarningsToExceptions']                     = $arguments['convertWarningsToExceptions'] ?? true;
1054
-        $arguments['crap4jThreshold']                                 = $arguments['crap4jThreshold'] ?? 30;
1055
-        $arguments['disallowTestOutput']                              = $arguments['disallowTestOutput'] ?? false;
1056
-        $arguments['disallowTodoAnnotatedTests']                      = $arguments['disallowTodoAnnotatedTests'] ?? false;
1057
-        $arguments['enforceTimeLimit']                                = $arguments['enforceTimeLimit'] ?? false;
1058
-        $arguments['excludeGroups']                                   = $arguments['excludeGroups'] ?? [];
1059
-        $arguments['failOnRisky']                                     = $arguments['failOnRisky'] ?? false;
1060
-        $arguments['failOnWarning']                                   = $arguments['failOnWarning'] ?? false;
1061
-        $arguments['groups']                                          = $arguments['groups'] ?? [];
1062
-        $arguments['processIsolation']                                = $arguments['processIsolation'] ?? false;
1063
-        $arguments['processUncoveredFilesFromWhitelist']              = $arguments['processUncoveredFilesFromWhitelist'] ?? false;
1064
-        $arguments['registerMockObjectsFromTestArgumentsRecursively'] = $arguments['registerMockObjectsFromTestArgumentsRecursively'] ?? false;
1065
-        $arguments['repeat']                                          = $arguments['repeat'] ?? false;
1066
-        $arguments['reportHighLowerBound']                            = $arguments['reportHighLowerBound'] ?? 90;
1067
-        $arguments['reportLowUpperBound']                             = $arguments['reportLowUpperBound'] ?? 50;
1068
-        $arguments['reportUselessTests']                              = $arguments['reportUselessTests'] ?? true;
1069
-        $arguments['reverseList']                                     = $arguments['reverseList'] ?? false;
1070
-        $arguments['stopOnError']                                     = $arguments['stopOnError'] ?? false;
1071
-        $arguments['stopOnFailure']                                   = $arguments['stopOnFailure'] ?? false;
1072
-        $arguments['stopOnIncomplete']                                = $arguments['stopOnIncomplete'] ?? false;
1073
-        $arguments['stopOnRisky']                                     = $arguments['stopOnRisky'] ?? false;
1074
-        $arguments['stopOnSkipped']                                   = $arguments['stopOnSkipped'] ?? false;
1075
-        $arguments['stopOnWarning']                                   = $arguments['stopOnWarning'] ?? false;
1076
-        $arguments['strictCoverage']                                  = $arguments['strictCoverage'] ?? false;
1077
-        $arguments['testdoxExcludeGroups']                            = $arguments['testdoxExcludeGroups'] ?? [];
1078
-        $arguments['testdoxGroups']                                   = $arguments['testdoxGroups'] ?? [];
1079
-        $arguments['timeoutForLargeTests']                            = $arguments['timeoutForLargeTests'] ?? 60;
1080
-        $arguments['timeoutForMediumTests']                           = $arguments['timeoutForMediumTests'] ?? 10;
1081
-        $arguments['timeoutForSmallTests']                            = $arguments['timeoutForSmallTests'] ?? 1;
1082
-        $arguments['verbose']                                         = $arguments['verbose'] ?? false;
1083
-    }
1084
-
1085
-    /**
1086
-     * @param string $type
1087
-     * @param string $message
1088
-     */
1089
-    private function writeMessage($type, $message)
1090
-    {
1091
-        if (!$this->messagePrinted) {
1092
-            $this->write("\n");
1093
-        }
1094
-
1095
-        $this->write(
1096
-            \sprintf(
1097
-                "%-15s%s\n",
1098
-                $type . ':',
1099
-                $message
1100
-            )
1101
-        );
1102
-
1103
-        $this->messagePrinted = true;
1104
-    }
55
+	const SUCCESS_EXIT   = 0;
56
+	const FAILURE_EXIT   = 1;
57
+	const EXCEPTION_EXIT = 2;
58
+
59
+	/**
60
+	 * @var CodeCoverageFilter
61
+	 */
62
+	protected $codeCoverageFilter;
63
+
64
+	/**
65
+	 * @var TestSuiteLoader
66
+	 */
67
+	protected $loader;
68
+
69
+	/**
70
+	 * @var ResultPrinter
71
+	 */
72
+	protected $printer;
73
+
74
+	/**
75
+	 * @var bool
76
+	 */
77
+	protected static $versionStringPrinted = false;
78
+
79
+	/**
80
+	 * @var Runtime
81
+	 */
82
+	private $runtime;
83
+
84
+	/**
85
+	 * @var bool
86
+	 */
87
+	private $messagePrinted = false;
88
+
89
+	/**
90
+	 * @param TestSuiteLoader    $loader
91
+	 * @param CodeCoverageFilter $filter
92
+	 */
93
+	public function __construct(TestSuiteLoader $loader = null, CodeCoverageFilter $filter = null)
94
+	{
95
+		if ($filter === null) {
96
+			$filter = new CodeCoverageFilter;
97
+		}
98
+
99
+		$this->codeCoverageFilter = $filter;
100
+		$this->loader             = $loader;
101
+		$this->runtime            = new Runtime;
102
+	}
103
+
104
+	/**
105
+	 * @param Test|ReflectionClass $test
106
+	 * @param array                $arguments
107
+	 *
108
+	 * @return TestResult
109
+	 *
110
+	 * @throws Exception
111
+	 */
112
+	public static function run($test, array $arguments = [])
113
+	{
114
+		if ($test instanceof ReflectionClass) {
115
+			$test = new TestSuite($test);
116
+		}
117
+
118
+		if ($test instanceof Test) {
119
+			$aTestRunner = new self;
120
+
121
+			return $aTestRunner->doRun(
122
+				$test,
123
+				$arguments
124
+			);
125
+		}
126
+
127
+		throw new Exception('No test case or test suite found.');
128
+	}
129
+
130
+	/**
131
+	 * @return TestResult
132
+	 */
133
+	protected function createTestResult()
134
+	{
135
+		return new TestResult;
136
+	}
137
+
138
+	/**
139
+	 * @param TestSuite $suite
140
+	 * @param array     $arguments
141
+	 */
142
+	private function processSuiteFilters(TestSuite $suite, array $arguments)
143
+	{
144
+		if (!$arguments['filter'] &&
145
+			empty($arguments['groups']) &&
146
+			empty($arguments['excludeGroups'])) {
147
+			return;
148
+		}
149
+
150
+		$filterFactory = new Factory;
151
+
152
+		if (!empty($arguments['excludeGroups'])) {
153
+			$filterFactory->addFilter(
154
+				new ReflectionClass(ExcludeGroupFilterIterator::class),
155
+				$arguments['excludeGroups']
156
+			);
157
+		}
158
+
159
+		if (!empty($arguments['groups'])) {
160
+			$filterFactory->addFilter(
161
+				new ReflectionClass(IncludeGroupFilterIterator::class),
162
+				$arguments['groups']
163
+			);
164
+		}
165
+
166
+		if ($arguments['filter']) {
167
+			$filterFactory->addFilter(
168
+				new ReflectionClass(NameFilterIterator::class),
169
+				$arguments['filter']
170
+			);
171
+		}
172
+
173
+		$suite->injectFilter($filterFactory);
174
+	}
175
+
176
+	/**
177
+	 * @param Test  $suite
178
+	 * @param array $arguments
179
+	 * @param bool  $exit
180
+	 *
181
+	 * @return TestResult
182
+	 */
183
+	public function doRun(Test $suite, array $arguments = [], $exit = true)
184
+	{
185
+		if (isset($arguments['configuration'])) {
186
+			$GLOBALS['__PHPUNIT_CONFIGURATION_FILE'] = $arguments['configuration'];
187
+		}
188
+
189
+		$this->handleConfiguration($arguments);
190
+
191
+		$this->processSuiteFilters($suite, $arguments);
192
+
193
+		if (isset($arguments['bootstrap'])) {
194
+			$GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap'];
195
+		}
196
+
197
+		if ($arguments['backupGlobals'] === true) {
198
+			$suite->setBackupGlobals(true);
199
+		}
200
+
201
+		if ($arguments['backupStaticAttributes'] === true) {
202
+			$suite->setBackupStaticAttributes(true);
203
+		}
204
+
205
+		if ($arguments['beStrictAboutChangesToGlobalState'] === true) {
206
+			$suite->setbeStrictAboutChangesToGlobalState(true);
207
+		}
208
+
209
+		if (\is_int($arguments['repeat']) && $arguments['repeat'] > 0) {
210
+			$_suite = new TestSuite;
211
+
212
+			foreach (\range(1, $arguments['repeat']) as $step) {
213
+				$_suite->addTest($suite);
214
+			}
215
+
216
+			$suite = $_suite;
217
+			unset($_suite);
218
+		}
219
+
220
+		$result = $this->createTestResult();
221
+
222
+		if (!$arguments['convertErrorsToExceptions']) {
223
+			$result->convertErrorsToExceptions(false);
224
+		}
225
+
226
+		if (!$arguments['convertDeprecationsToExceptions']) {
227
+			Deprecated::$enabled = false;
228
+		}
229
+
230
+		if (!$arguments['convertNoticesToExceptions']) {
231
+			Notice::$enabled = false;
232
+		}
233
+
234
+		if (!$arguments['convertWarningsToExceptions']) {
235
+			Warning::$enabled = false;
236
+		}
237
+
238
+		if ($arguments['stopOnError']) {
239
+			$result->stopOnError(true);
240
+		}
241
+
242
+		if ($arguments['stopOnFailure']) {
243
+			$result->stopOnFailure(true);
244
+		}
245
+
246
+		if ($arguments['stopOnWarning']) {
247
+			$result->stopOnWarning(true);
248
+		}
249
+
250
+		if ($arguments['stopOnIncomplete']) {
251
+			$result->stopOnIncomplete(true);
252
+		}
253
+
254
+		if ($arguments['stopOnRisky']) {
255
+			$result->stopOnRisky(true);
256
+		}
257
+
258
+		if ($arguments['stopOnSkipped']) {
259
+			$result->stopOnSkipped(true);
260
+		}
261
+
262
+		if ($arguments['registerMockObjectsFromTestArgumentsRecursively']) {
263
+			$result->setRegisterMockObjectsFromTestArgumentsRecursively(true);
264
+		}
265
+
266
+		if ($this->printer === null) {
267
+			if (isset($arguments['printer']) &&
268
+				$arguments['printer'] instanceof Printer) {
269
+				$this->printer = $arguments['printer'];
270
+			} else {
271
+				$printerClass = ResultPrinter::class;
272
+
273
+				if (isset($arguments['printer']) && \is_string($arguments['printer']) && \class_exists($arguments['printer'], false)) {
274
+					$class = new ReflectionClass($arguments['printer']);
275
+
276
+					if ($class->isSubclassOf(ResultPrinter::class)) {
277
+						$printerClass = $arguments['printer'];
278
+					}
279
+				}
280
+
281
+				$this->printer = new $printerClass(
282
+					(isset($arguments['stderr']) && $arguments['stderr'] === true) ? 'php://stderr' : null,
283
+					$arguments['verbose'],
284
+					$arguments['colors'],
285
+					$arguments['debug'],
286
+					$arguments['columns'],
287
+					$arguments['reverseList']
288
+				);
289
+			}
290
+		}
291
+
292
+		$this->printer->write(
293
+			Version::getVersionString() . "\n"
294
+		);
295
+
296
+		self::$versionStringPrinted = true;
297
+
298
+		if ($arguments['verbose']) {
299
+			$runtime = $this->runtime->getNameWithVersion();
300
+
301
+			if ($this->runtime->hasXdebug()) {
302
+				$runtime .= \sprintf(
303
+					' with Xdebug %s',
304
+					\phpversion('xdebug')
305
+				);
306
+			}
307
+
308
+			$this->writeMessage('Runtime', $runtime);
309
+
310
+			if (isset($arguments['configuration'])) {
311
+				$this->writeMessage(
312
+					'Configuration',
313
+					$arguments['configuration']->getFilename()
314
+				);
315
+			}
316
+
317
+			foreach ($arguments['loadedExtensions'] as $extension) {
318
+				$this->writeMessage(
319
+					'Extension',
320
+					$extension
321
+				);
322
+			}
323
+
324
+			foreach ($arguments['notLoadedExtensions'] as $extension) {
325
+				$this->writeMessage(
326
+					'Extension',
327
+					$extension
328
+				);
329
+			}
330
+		}
331
+
332
+		if ($this->runtime->discardsComments()) {
333
+			$this->writeMessage('Warning', 'opcache.save_comments=0 set; annotations will not work');
334
+		}
335
+
336
+		foreach ($arguments['listeners'] as $listener) {
337
+			$result->addListener($listener);
338
+		}
339
+
340
+		$result->addListener($this->printer);
341
+
342
+		$codeCoverageReports = 0;
343
+
344
+		if (!isset($arguments['noLogging'])) {
345
+			if (isset($arguments['testdoxHTMLFile'])) {
346
+				$result->addListener(
347
+					new HtmlResultPrinter(
348
+						$arguments['testdoxHTMLFile'],
349
+						$arguments['testdoxGroups'],
350
+						$arguments['testdoxExcludeGroups']
351
+					)
352
+				);
353
+			}
354
+
355
+			if (isset($arguments['testdoxTextFile'])) {
356
+				$result->addListener(
357
+					new TextResultPrinter(
358
+						$arguments['testdoxTextFile'],
359
+						$arguments['testdoxGroups'],
360
+						$arguments['testdoxExcludeGroups']
361
+					)
362
+				);
363
+			}
364
+
365
+			if (isset($arguments['testdoxXMLFile'])) {
366
+				$result->addListener(
367
+					new XmlResultPrinter(
368
+						$arguments['testdoxXMLFile']
369
+					)
370
+				);
371
+			}
372
+
373
+			if (isset($arguments['teamcityLogfile'])) {
374
+				$result->addListener(
375
+					new TeamCity($arguments['teamcityLogfile'])
376
+				);
377
+			}
378
+
379
+			if (isset($arguments['junitLogfile'])) {
380
+				$result->addListener(
381
+					new JUnit(
382
+						$arguments['junitLogfile'],
383
+						$arguments['reportUselessTests']
384
+					)
385
+				);
386
+			}
387
+
388
+			if (isset($arguments['coverageClover'])) {
389
+				$codeCoverageReports++;
390
+			}
391
+
392
+			if (isset($arguments['coverageCrap4J'])) {
393
+				$codeCoverageReports++;
394
+			}
395
+
396
+			if (isset($arguments['coverageHtml'])) {
397
+				$codeCoverageReports++;
398
+			}
399
+
400
+			if (isset($arguments['coveragePHP'])) {
401
+				$codeCoverageReports++;
402
+			}
403
+
404
+			if (isset($arguments['coverageText'])) {
405
+				$codeCoverageReports++;
406
+			}
407
+
408
+			if (isset($arguments['coverageXml'])) {
409
+				$codeCoverageReports++;
410
+			}
411
+		}
412
+
413
+		if (isset($arguments['noCoverage'])) {
414
+			$codeCoverageReports = 0;
415
+		}
416
+
417
+		if ($codeCoverageReports > 0 && !$this->runtime->canCollectCodeCoverage()) {
418
+			$this->writeMessage('Error', 'No code coverage driver is available');
419
+
420
+			$codeCoverageReports = 0;
421
+		}
422
+
423
+		if ($codeCoverageReports > 0) {
424
+			$codeCoverage = new CodeCoverage(
425
+				null,
426
+				$this->codeCoverageFilter
427
+			);
428
+
429
+			$codeCoverage->setUnintentionallyCoveredSubclassesWhitelist(
430
+				[SebastianBergmann\Comparator\Comparator::class]
431
+			);
432
+
433
+			$codeCoverage->setCheckForUnintentionallyCoveredCode(
434
+				$arguments['strictCoverage']
435
+			);
436
+
437
+			$codeCoverage->setCheckForMissingCoversAnnotation(
438
+				$arguments['strictCoverage']
439
+			);
440
+
441
+			if (isset($arguments['forceCoversAnnotation'])) {
442
+				$codeCoverage->setForceCoversAnnotation(
443
+					$arguments['forceCoversAnnotation']
444
+				);
445
+			}
446
+
447
+			if (isset($arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'])) {
448
+				$codeCoverage->setIgnoreDeprecatedCode(
449
+					$arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage']
450
+				);
451
+			}
452
+
453
+			if (isset($arguments['disableCodeCoverageIgnore'])) {
454
+				$codeCoverage->setDisableIgnoredLines(true);
455
+			}
456
+
457
+			if (isset($arguments['whitelist'])) {
458
+				$this->codeCoverageFilter->addDirectoryToWhitelist($arguments['whitelist']);
459
+			}
460
+
461
+			if (isset($arguments['configuration'])) {
462
+				$filterConfiguration = $arguments['configuration']->getFilterConfiguration();
463
+
464
+				if (empty($filterConfiguration['whitelist']) && !isset($arguments['whitelist'])) {
465
+					$this->writeMessage('Error', 'No whitelist is configured, no code coverage will be generated.');
466
+
467
+					$codeCoverageReports = 0;
468
+
469
+					unset($codeCoverage);
470
+				} else {
471
+					$codeCoverage->setAddUncoveredFilesFromWhitelist(
472
+						$filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist']
473
+					);
474
+
475
+					$codeCoverage->setProcessUncoveredFilesFromWhitelist(
476
+						$filterConfiguration['whitelist']['processUncoveredFilesFromWhitelist']
477
+					);
478
+
479
+					foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
480
+						$this->codeCoverageFilter->addDirectoryToWhitelist(
481
+							$dir['path'],
482
+							$dir['suffix'],
483
+							$dir['prefix']
484
+						);
485
+					}
486
+
487
+					foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
488
+						$this->codeCoverageFilter->addFileToWhitelist($file);
489
+					}
490
+
491
+					foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
492
+						$this->codeCoverageFilter->removeDirectoryFromWhitelist(
493
+							$dir['path'],
494
+							$dir['suffix'],
495
+							$dir['prefix']
496
+						);
497
+					}
498
+
499
+					foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
500
+						$this->codeCoverageFilter->removeFileFromWhitelist($file);
501
+					}
502
+				}
503
+			}
504
+
505
+			if (isset($codeCoverage) && !$this->codeCoverageFilter->hasWhitelist()) {
506
+				$this->writeMessage('Error', 'Incorrect whitelist config, no code coverage will be generated.');
507
+
508
+				$codeCoverageReports = 0;
509
+
510
+				unset($codeCoverage);
511
+			}
512
+		}
513
+
514
+		$this->printer->write("\n");
515
+
516
+		if (isset($codeCoverage)) {
517
+			$result->setCodeCoverage($codeCoverage);
518
+
519
+			if ($codeCoverageReports > 1 && isset($arguments['cacheTokens'])) {
520
+				$codeCoverage->setCacheTokens($arguments['cacheTokens']);
521
+			}
522
+		}
523
+
524
+		$result->beStrictAboutTestsThatDoNotTestAnything($arguments['reportUselessTests']);
525
+		$result->beStrictAboutOutputDuringTests($arguments['disallowTestOutput']);
526
+		$result->beStrictAboutTodoAnnotatedTests($arguments['disallowTodoAnnotatedTests']);
527
+		$result->beStrictAboutResourceUsageDuringSmallTests($arguments['beStrictAboutResourceUsageDuringSmallTests']);
528
+		$result->enforceTimeLimit($arguments['enforceTimeLimit']);
529
+		$result->setTimeoutForSmallTests($arguments['timeoutForSmallTests']);
530
+		$result->setTimeoutForMediumTests($arguments['timeoutForMediumTests']);
531
+		$result->setTimeoutForLargeTests($arguments['timeoutForLargeTests']);
532
+
533
+		if ($suite instanceof TestSuite) {
534
+			$suite->setRunTestInSeparateProcess($arguments['processIsolation']);
535
+		}
536
+
537
+		$suite->run($result);
538
+
539
+		unset($suite);
540
+		$result->flushListeners();
541
+
542
+		if ($this->printer instanceof ResultPrinter) {
543
+			$this->printer->printResult($result);
544
+		}
545
+
546
+		if (isset($codeCoverage)) {
547
+			if (isset($arguments['coverageClover'])) {
548
+				$this->printer->write(
549
+					"\nGenerating code coverage report in Clover XML format ..."
550
+				);
551
+
552
+				try {
553
+					$writer = new CloverReport;
554
+					$writer->process($codeCoverage, $arguments['coverageClover']);
555
+
556
+					$this->printer->write(" done\n");
557
+					unset($writer);
558
+				} catch (CodeCoverageException $e) {
559
+					$this->printer->write(
560
+						" failed\n" . $e->getMessage() . "\n"
561
+					);
562
+				}
563
+			}
564
+
565
+			if (isset($arguments['coverageCrap4J'])) {
566
+				$this->printer->write(
567
+					"\nGenerating Crap4J report XML file ..."
568
+				);
569
+
570
+				try {
571
+					$writer = new Crap4jReport($arguments['crap4jThreshold']);
572
+					$writer->process($codeCoverage, $arguments['coverageCrap4J']);
573
+
574
+					$this->printer->write(" done\n");
575
+					unset($writer);
576
+				} catch (CodeCoverageException $e) {
577
+					$this->printer->write(
578
+						" failed\n" . $e->getMessage() . "\n"
579
+					);
580
+				}
581
+			}
582
+
583
+			if (isset($arguments['coverageHtml'])) {
584
+				$this->printer->write(
585
+					"\nGenerating code coverage report in HTML format ..."
586
+				);
587
+
588
+				try {
589
+					$writer = new HtmlReport(
590
+						$arguments['reportLowUpperBound'],
591
+						$arguments['reportHighLowerBound'],
592
+						\sprintf(
593
+							' and <a href="https://phpunit.de/">PHPUnit %s</a>',
594
+							Version::id()
595
+						)
596
+					);
597
+
598
+					$writer->process($codeCoverage, $arguments['coverageHtml']);
599
+
600
+					$this->printer->write(" done\n");
601
+					unset($writer);
602
+				} catch (CodeCoverageException $e) {
603
+					$this->printer->write(
604
+						" failed\n" . $e->getMessage() . "\n"
605
+					);
606
+				}
607
+			}
608
+
609
+			if (isset($arguments['coveragePHP'])) {
610
+				$this->printer->write(
611
+					"\nGenerating code coverage report in PHP format ..."
612
+				);
613
+
614
+				try {
615
+					$writer = new PhpReport;
616
+					$writer->process($codeCoverage, $arguments['coveragePHP']);
617
+
618
+					$this->printer->write(" done\n");
619
+					unset($writer);
620
+				} catch (CodeCoverageException $e) {
621
+					$this->printer->write(
622
+						" failed\n" . $e->getMessage() . "\n"
623
+					);
624
+				}
625
+			}
626
+
627
+			if (isset($arguments['coverageText'])) {
628
+				if ($arguments['coverageText'] == 'php://stdout') {
629
+					$outputStream = $this->printer;
630
+					$colors       = $arguments['colors'] && $arguments['colors'] != ResultPrinter::COLOR_NEVER;
631
+				} else {
632
+					$outputStream = new Printer($arguments['coverageText']);
633
+					$colors       = false;
634
+				}
635
+
636
+				$processor = new TextReport(
637
+					$arguments['reportLowUpperBound'],
638
+					$arguments['reportHighLowerBound'],
639
+					$arguments['coverageTextShowUncoveredFiles'],
640
+					$arguments['coverageTextShowOnlySummary']
641
+				);
642
+
643
+				$outputStream->write(
644
+					$processor->process($codeCoverage, $colors)
645
+				);
646
+			}
647
+
648
+			if (isset($arguments['coverageXml'])) {
649
+				$this->printer->write(
650
+					"\nGenerating code coverage report in PHPUnit XML format ..."
651
+				);
652
+
653
+				try {
654
+					$writer = new XmlReport(Version::id());
655
+					$writer->process($codeCoverage, $arguments['coverageXml']);
656
+
657
+					$this->printer->write(" done\n");
658
+					unset($writer);
659
+				} catch (CodeCoverageException $e) {
660
+					$this->printer->write(
661
+						" failed\n" . $e->getMessage() . "\n"
662
+					);
663
+				}
664
+			}
665
+		}
666
+
667
+		if ($exit) {
668
+			if ($result->wasSuccessful()) {
669
+				if ($arguments['failOnRisky'] && !$result->allHarmless()) {
670
+					exit(self::FAILURE_EXIT);
671
+				}
672
+
673
+				if ($arguments['failOnWarning'] && $result->warningCount() > 0) {
674
+					exit(self::FAILURE_EXIT);
675
+				}
676
+
677
+				exit(self::SUCCESS_EXIT);
678
+			}
679
+
680
+			if ($result->errorCount() > 0) {
681
+				exit(self::EXCEPTION_EXIT);
682
+			}
683
+
684
+			if ($result->failureCount() > 0) {
685
+				exit(self::FAILURE_EXIT);
686
+			}
687
+		}
688
+
689
+		return $result;
690
+	}
691
+
692
+	/**
693
+	 * @param ResultPrinter $resultPrinter
694
+	 */
695
+	public function setPrinter(ResultPrinter $resultPrinter)
696
+	{
697
+		$this->printer = $resultPrinter;
698
+	}
699
+
700
+	/**
701
+	 * Override to define how to handle a failed loading of
702
+	 * a test suite.
703
+	 *
704
+	 * @param string $message
705
+	 */
706
+	protected function runFailed($message)
707
+	{
708
+		$this->write($message . PHP_EOL);
709
+		exit(self::FAILURE_EXIT);
710
+	}
711
+
712
+	/**
713
+	 * @param string $buffer
714
+	 */
715
+	protected function write($buffer)
716
+	{
717
+		if (PHP_SAPI != 'cli' && PHP_SAPI != 'phpdbg') {
718
+			$buffer = \htmlspecialchars($buffer);
719
+		}
720
+
721
+		if ($this->printer !== null) {
722
+			$this->printer->write($buffer);
723
+		} else {
724
+			print $buffer;
725
+		}
726
+	}
727
+
728
+	/**
729
+	 * Returns the loader to be used.
730
+	 *
731
+	 * @return TestSuiteLoader
732
+	 */
733
+	public function getLoader()
734
+	{
735
+		if ($this->loader === null) {
736
+			$this->loader = new StandardTestSuiteLoader;
737
+		}
738
+
739
+		return $this->loader;
740
+	}
741
+
742
+	/**
743
+	 * @param array $arguments
744
+	 */
745
+	protected function handleConfiguration(array &$arguments)
746
+	{
747
+		if (isset($arguments['configuration']) &&
748
+			!$arguments['configuration'] instanceof Configuration) {
749
+			$arguments['configuration'] = Configuration::getInstance(
750
+				$arguments['configuration']
751
+			);
752
+		}
753
+
754
+		$arguments['debug']     = $arguments['debug'] ?? false;
755
+		$arguments['filter']    = $arguments['filter'] ?? false;
756
+		$arguments['listeners'] = $arguments['listeners'] ?? [];
757
+
758
+		if (isset($arguments['configuration'])) {
759
+			$arguments['configuration']->handlePHPConfiguration();
760
+
761
+			$phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
762
+
763
+			if (isset($phpunitConfiguration['backupGlobals']) && !isset($arguments['backupGlobals'])) {
764
+				$arguments['backupGlobals'] = $phpunitConfiguration['backupGlobals'];
765
+			}
766
+
767
+			if (isset($phpunitConfiguration['backupStaticAttributes']) && !isset($arguments['backupStaticAttributes'])) {
768
+				$arguments['backupStaticAttributes'] = $phpunitConfiguration['backupStaticAttributes'];
769
+			}
770
+
771
+			if (isset($phpunitConfiguration['beStrictAboutChangesToGlobalState']) && !isset($arguments['beStrictAboutChangesToGlobalState'])) {
772
+				$arguments['beStrictAboutChangesToGlobalState'] = $phpunitConfiguration['beStrictAboutChangesToGlobalState'];
773
+			}
774
+
775
+			if (isset($phpunitConfiguration['bootstrap']) && !isset($arguments['bootstrap'])) {
776
+				$arguments['bootstrap'] = $phpunitConfiguration['bootstrap'];
777
+			}
778
+
779
+			if (isset($phpunitConfiguration['cacheTokens']) && !isset($arguments['cacheTokens'])) {
780
+				$arguments['cacheTokens'] = $phpunitConfiguration['cacheTokens'];
781
+			}
782
+
783
+			if (isset($phpunitConfiguration['colors']) && !isset($arguments['colors'])) {
784
+				$arguments['colors'] = $phpunitConfiguration['colors'];
785
+			}
786
+
787
+			if (isset($phpunitConfiguration['convertDeprecationsToExceptions']) && !isset($arguments['convertDeprecationsToExceptions'])) {
788
+				$arguments['convertDeprecationsToExceptions'] = $phpunitConfiguration['convertDeprecationsToExceptions'];
789
+			}
790
+
791
+			if (isset($phpunitConfiguration['convertErrorsToExceptions']) && !isset($arguments['convertErrorsToExceptions'])) {
792
+				$arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions'];
793
+			}
794
+
795
+			if (isset($phpunitConfiguration['convertNoticesToExceptions']) && !isset($arguments['convertNoticesToExceptions'])) {
796
+				$arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions'];
797
+			}
798
+
799
+			if (isset($phpunitConfiguration['convertWarningsToExceptions']) && !isset($arguments['convertWarningsToExceptions'])) {
800
+				$arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions'];
801
+			}
802
+
803
+			if (isset($phpunitConfiguration['processIsolation']) && !isset($arguments['processIsolation'])) {
804
+				$arguments['processIsolation'] = $phpunitConfiguration['processIsolation'];
805
+			}
806
+
807
+			if (isset($phpunitConfiguration['stopOnError']) && !isset($arguments['stopOnError'])) {
808
+				$arguments['stopOnError'] = $phpunitConfiguration['stopOnError'];
809
+			}
810
+
811
+			if (isset($phpunitConfiguration['stopOnFailure']) && !isset($arguments['stopOnFailure'])) {
812
+				$arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
813
+			}
814
+
815
+			if (isset($phpunitConfiguration['stopOnWarning']) && !isset($arguments['stopOnWarning'])) {
816
+				$arguments['stopOnWarning'] = $phpunitConfiguration['stopOnWarning'];
817
+			}
818
+
819
+			if (isset($phpunitConfiguration['stopOnIncomplete']) && !isset($arguments['stopOnIncomplete'])) {
820
+				$arguments['stopOnIncomplete'] = $phpunitConfiguration['stopOnIncomplete'];
821
+			}
822
+
823
+			if (isset($phpunitConfiguration['stopOnRisky']) && !isset($arguments['stopOnRisky'])) {
824
+				$arguments['stopOnRisky'] = $phpunitConfiguration['stopOnRisky'];
825
+			}
826
+
827
+			if (isset($phpunitConfiguration['stopOnSkipped']) && !isset($arguments['stopOnSkipped'])) {
828
+				$arguments['stopOnSkipped'] = $phpunitConfiguration['stopOnSkipped'];
829
+			}
830
+
831
+			if (isset($phpunitConfiguration['failOnWarning']) && !isset($arguments['failOnWarning'])) {
832
+				$arguments['failOnWarning'] = $phpunitConfiguration['failOnWarning'];
833
+			}
834
+
835
+			if (isset($phpunitConfiguration['failOnRisky']) && !isset($arguments['failOnRisky'])) {
836
+				$arguments['failOnRisky'] = $phpunitConfiguration['failOnRisky'];
837
+			}
838
+
839
+			if (isset($phpunitConfiguration['timeoutForSmallTests']) && !isset($arguments['timeoutForSmallTests'])) {
840
+				$arguments['timeoutForSmallTests'] = $phpunitConfiguration['timeoutForSmallTests'];
841
+			}
842
+
843
+			if (isset($phpunitConfiguration['timeoutForMediumTests']) && !isset($arguments['timeoutForMediumTests'])) {
844
+				$arguments['timeoutForMediumTests'] = $phpunitConfiguration['timeoutForMediumTests'];
845
+			}
846
+
847
+			if (isset($phpunitConfiguration['timeoutForLargeTests']) && !isset($arguments['timeoutForLargeTests'])) {
848
+				$arguments['timeoutForLargeTests'] = $phpunitConfiguration['timeoutForLargeTests'];
849
+			}
850
+
851
+			if (isset($phpunitConfiguration['reportUselessTests']) && !isset($arguments['reportUselessTests'])) {
852
+				$arguments['reportUselessTests'] = $phpunitConfiguration['reportUselessTests'];
853
+			}
854
+
855
+			if (isset($phpunitConfiguration['strictCoverage']) && !isset($arguments['strictCoverage'])) {
856
+				$arguments['strictCoverage'] = $phpunitConfiguration['strictCoverage'];
857
+			}
858
+
859
+			if (isset($phpunitConfiguration['ignoreDeprecatedCodeUnitsFromCodeCoverage']) && !isset($arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'])) {
860
+				$arguments['ignoreDeprecatedCodeUnitsFromCodeCoverage'] = $phpunitConfiguration['ignoreDeprecatedCodeUnitsFromCodeCoverage'];
861
+			}
862
+
863
+			if (isset($phpunitConfiguration['disallowTestOutput']) && !isset($arguments['disallowTestOutput'])) {
864
+				$arguments['disallowTestOutput'] = $phpunitConfiguration['disallowTestOutput'];
865
+			}
866
+
867
+			if (isset($phpunitConfiguration['enforceTimeLimit']) && !isset($arguments['enforceTimeLimit'])) {
868
+				$arguments['enforceTimeLimit'] = $phpunitConfiguration['enforceTimeLimit'];
869
+			}
870
+
871
+			if (isset($phpunitConfiguration['disallowTodoAnnotatedTests']) && !isset($arguments['disallowTodoAnnotatedTests'])) {
872
+				$arguments['disallowTodoAnnotatedTests'] = $phpunitConfiguration['disallowTodoAnnotatedTests'];
873
+			}
874
+
875
+			if (isset($phpunitConfiguration['beStrictAboutResourceUsageDuringSmallTests']) && !isset($arguments['beStrictAboutResourceUsageDuringSmallTests'])) {
876
+				$arguments['beStrictAboutResourceUsageDuringSmallTests'] = $phpunitConfiguration['beStrictAboutResourceUsageDuringSmallTests'];
877
+			}
878
+
879
+			if (isset($phpunitConfiguration['verbose']) && !isset($arguments['verbose'])) {
880
+				$arguments['verbose'] = $phpunitConfiguration['verbose'];
881
+			}
882
+
883
+			if (isset($phpunitConfiguration['reverseDefectList']) && !isset($arguments['reverseList'])) {
884
+				$arguments['reverseList'] = $phpunitConfiguration['reverseDefectList'];
885
+			}
886
+
887
+			if (isset($phpunitConfiguration['forceCoversAnnotation']) && !isset($arguments['forceCoversAnnotation'])) {
888
+				$arguments['forceCoversAnnotation'] = $phpunitConfiguration['forceCoversAnnotation'];
889
+			}
890
+
891
+			if (isset($phpunitConfiguration['disableCodeCoverageIgnore']) && !isset($arguments['disableCodeCoverageIgnore'])) {
892
+				$arguments['disableCodeCoverageIgnore'] = $phpunitConfiguration['disableCodeCoverageIgnore'];
893
+			}
894
+
895
+			if (isset($phpunitConfiguration['registerMockObjectsFromTestArgumentsRecursively']) && !isset($arguments['registerMockObjectsFromTestArgumentsRecursively'])) {
896
+				$arguments['registerMockObjectsFromTestArgumentsRecursively'] = $phpunitConfiguration['registerMockObjectsFromTestArgumentsRecursively'];
897
+			}
898
+
899
+			$groupCliArgs = [];
900
+
901
+			if (!empty($arguments['groups'])) {
902
+				$groupCliArgs = $arguments['groups'];
903
+			}
904
+
905
+			$groupConfiguration = $arguments['configuration']->getGroupConfiguration();
906
+
907
+			if (!empty($groupConfiguration['include']) && !isset($arguments['groups'])) {
908
+				$arguments['groups'] = $groupConfiguration['include'];
909
+			}
910
+
911
+			if (!empty($groupConfiguration['exclude']) && !isset($arguments['excludeGroups'])) {
912
+				$arguments['excludeGroups'] = \array_diff($groupConfiguration['exclude'], $groupCliArgs);
913
+			}
914
+
915
+			foreach ($arguments['configuration']->getListenerConfiguration() as $listener) {
916
+				if (!\class_exists($listener['class'], false) &&
917
+					$listener['file'] !== '') {
918
+					require_once $listener['file'];
919
+				}
920
+
921
+				if (!\class_exists($listener['class'])) {
922
+					throw new Exception(
923
+						\sprintf(
924
+							'Class "%s" does not exist',
925
+							$listener['class']
926
+						)
927
+					);
928
+				}
929
+
930
+				$listenerClass = new ReflectionClass($listener['class']);
931
+
932
+				if (!$listenerClass->implementsInterface(TestListener::class)) {
933
+					throw new Exception(
934
+						\sprintf(
935
+							'Class "%s" does not implement the PHPUnit\Framework\TestListener interface',
936
+							$listener['class']
937
+						)
938
+					);
939
+				}
940
+
941
+				if (\count($listener['arguments']) == 0) {
942
+					$listener = new $listener['class'];
943
+				} else {
944
+					$listener = $listenerClass->newInstanceArgs(
945
+						$listener['arguments']
946
+					);
947
+				}
948
+
949
+				$arguments['listeners'][] = $listener;
950
+			}
951
+
952
+			$loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
953
+
954
+			if (isset($loggingConfiguration['coverage-clover']) && !isset($arguments['coverageClover'])) {
955
+				$arguments['coverageClover'] = $loggingConfiguration['coverage-clover'];
956
+			}
957
+
958
+			if (isset($loggingConfiguration['coverage-crap4j']) && !isset($arguments['coverageCrap4J'])) {
959
+				$arguments['coverageCrap4J'] = $loggingConfiguration['coverage-crap4j'];
960
+
961
+				if (isset($loggingConfiguration['crap4jThreshold']) && !isset($arguments['crap4jThreshold'])) {
962
+					$arguments['crap4jThreshold'] = $loggingConfiguration['crap4jThreshold'];
963
+				}
964
+			}
965
+
966
+			if (isset($loggingConfiguration['coverage-html']) && !isset($arguments['coverageHtml'])) {
967
+				if (isset($loggingConfiguration['lowUpperBound']) && !isset($arguments['reportLowUpperBound'])) {
968
+					$arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound'];
969
+				}
970
+
971
+				if (isset($loggingConfiguration['highLowerBound']) && !isset($arguments['reportHighLowerBound'])) {
972
+					$arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound'];
973
+				}
974
+
975
+				$arguments['coverageHtml'] = $loggingConfiguration['coverage-html'];
976
+			}
977
+
978
+			if (isset($loggingConfiguration['coverage-php']) && !isset($arguments['coveragePHP'])) {
979
+				$arguments['coveragePHP'] = $loggingConfiguration['coverage-php'];
980
+			}
981
+
982
+			if (isset($loggingConfiguration['coverage-text']) && !isset($arguments['coverageText'])) {
983
+				$arguments['coverageText'] = $loggingConfiguration['coverage-text'];
984
+
985
+				if (isset($loggingConfiguration['coverageTextShowUncoveredFiles'])) {
986
+					$arguments['coverageTextShowUncoveredFiles'] = $loggingConfiguration['coverageTextShowUncoveredFiles'];
987
+				} else {
988
+					$arguments['coverageTextShowUncoveredFiles'] = false;
989
+				}
990
+
991
+				if (isset($loggingConfiguration['coverageTextShowOnlySummary'])) {
992
+					$arguments['coverageTextShowOnlySummary'] = $loggingConfiguration['coverageTextShowOnlySummary'];
993
+				} else {
994
+					$arguments['coverageTextShowOnlySummary'] = false;
995
+				}
996
+			}
997
+
998
+			if (isset($loggingConfiguration['coverage-xml']) && !isset($arguments['coverageXml'])) {
999
+				$arguments['coverageXml'] = $loggingConfiguration['coverage-xml'];
1000
+			}
1001
+
1002
+			if (isset($loggingConfiguration['plain'])) {
1003
+				$arguments['listeners'][] = new ResultPrinter(
1004
+					$loggingConfiguration['plain'],
1005
+					true
1006
+				);
1007
+			}
1008
+
1009
+			if (isset($loggingConfiguration['teamcity']) && !isset($arguments['teamcityLogfile'])) {
1010
+				$arguments['teamcityLogfile'] = $loggingConfiguration['teamcity'];
1011
+			}
1012
+
1013
+			if (isset($loggingConfiguration['junit']) && !isset($arguments['junitLogfile'])) {
1014
+				$arguments['junitLogfile'] = $loggingConfiguration['junit'];
1015
+			}
1016
+
1017
+			if (isset($loggingConfiguration['testdox-html']) && !isset($arguments['testdoxHTMLFile'])) {
1018
+				$arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html'];
1019
+			}
1020
+
1021
+			if (isset($loggingConfiguration['testdox-text']) && !isset($arguments['testdoxTextFile'])) {
1022
+				$arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text'];
1023
+			}
1024
+
1025
+			if (isset($loggingConfiguration['testdox-xml']) && !isset($arguments['testdoxXMLFile'])) {
1026
+				$arguments['testdoxXMLFile'] = $loggingConfiguration['testdox-xml'];
1027
+			}
1028
+
1029
+			$testdoxGroupConfiguration = $arguments['configuration']->getTestdoxGroupConfiguration();
1030
+
1031
+			if (isset($testdoxGroupConfiguration['include']) &&
1032
+				!isset($arguments['testdoxGroups'])) {
1033
+				$arguments['testdoxGroups'] = $testdoxGroupConfiguration['include'];
1034
+			}
1035
+
1036
+			if (isset($testdoxGroupConfiguration['exclude']) &&
1037
+				!isset($arguments['testdoxExcludeGroups'])) {
1038
+				$arguments['testdoxExcludeGroups'] = $testdoxGroupConfiguration['exclude'];
1039
+			}
1040
+		}
1041
+
1042
+		$arguments['addUncoveredFilesFromWhitelist']                  = $arguments['addUncoveredFilesFromWhitelist'] ?? true;
1043
+		$arguments['backupGlobals']                                   = $arguments['backupGlobals'] ?? null;
1044
+		$arguments['backupStaticAttributes']                          = $arguments['backupStaticAttributes'] ?? null;
1045
+		$arguments['beStrictAboutChangesToGlobalState']               = $arguments['beStrictAboutChangesToGlobalState'] ?? null;
1046
+		$arguments['beStrictAboutResourceUsageDuringSmallTests']      = $arguments['beStrictAboutResourceUsageDuringSmallTests'] ?? false;
1047
+		$arguments['cacheTokens']                                     = $arguments['cacheTokens'] ?? false;
1048
+		$arguments['colors']                                          = $arguments['colors'] ?? ResultPrinter::COLOR_DEFAULT;
1049
+		$arguments['columns']                                         = $arguments['columns'] ?? 80;
1050
+		$arguments['convertDeprecationsToExceptions']                 = $arguments['convertDeprecationsToExceptions'] ?? true;
1051
+		$arguments['convertErrorsToExceptions']                       = $arguments['convertErrorsToExceptions'] ?? true;
1052
+		$arguments['convertNoticesToExceptions']                      = $arguments['convertNoticesToExceptions'] ?? true;
1053
+		$arguments['convertWarningsToExceptions']                     = $arguments['convertWarningsToExceptions'] ?? true;
1054
+		$arguments['crap4jThreshold']                                 = $arguments['crap4jThreshold'] ?? 30;
1055
+		$arguments['disallowTestOutput']                              = $arguments['disallowTestOutput'] ?? false;
1056
+		$arguments['disallowTodoAnnotatedTests']                      = $arguments['disallowTodoAnnotatedTests'] ?? false;
1057
+		$arguments['enforceTimeLimit']                                = $arguments['enforceTimeLimit'] ?? false;
1058
+		$arguments['excludeGroups']                                   = $arguments['excludeGroups'] ?? [];
1059
+		$arguments['failOnRisky']                                     = $arguments['failOnRisky'] ?? false;
1060
+		$arguments['failOnWarning']                                   = $arguments['failOnWarning'] ?? false;
1061
+		$arguments['groups']                                          = $arguments['groups'] ?? [];
1062
+		$arguments['processIsolation']                                = $arguments['processIsolation'] ?? false;
1063
+		$arguments['processUncoveredFilesFromWhitelist']              = $arguments['processUncoveredFilesFromWhitelist'] ?? false;
1064
+		$arguments['registerMockObjectsFromTestArgumentsRecursively'] = $arguments['registerMockObjectsFromTestArgumentsRecursively'] ?? false;
1065
+		$arguments['repeat']                                          = $arguments['repeat'] ?? false;
1066
+		$arguments['reportHighLowerBound']                            = $arguments['reportHighLowerBound'] ?? 90;
1067
+		$arguments['reportLowUpperBound']                             = $arguments['reportLowUpperBound'] ?? 50;
1068
+		$arguments['reportUselessTests']                              = $arguments['reportUselessTests'] ?? true;
1069
+		$arguments['reverseList']                                     = $arguments['reverseList'] ?? false;
1070
+		$arguments['stopOnError']                                     = $arguments['stopOnError'] ?? false;
1071
+		$arguments['stopOnFailure']                                   = $arguments['stopOnFailure'] ?? false;
1072
+		$arguments['stopOnIncomplete']                                = $arguments['stopOnIncomplete'] ?? false;
1073
+		$arguments['stopOnRisky']                                     = $arguments['stopOnRisky'] ?? false;
1074
+		$arguments['stopOnSkipped']                                   = $arguments['stopOnSkipped'] ?? false;
1075
+		$arguments['stopOnWarning']                                   = $arguments['stopOnWarning'] ?? false;
1076
+		$arguments['strictCoverage']                                  = $arguments['strictCoverage'] ?? false;
1077
+		$arguments['testdoxExcludeGroups']                            = $arguments['testdoxExcludeGroups'] ?? [];
1078
+		$arguments['testdoxGroups']                                   = $arguments['testdoxGroups'] ?? [];
1079
+		$arguments['timeoutForLargeTests']                            = $arguments['timeoutForLargeTests'] ?? 60;
1080
+		$arguments['timeoutForMediumTests']                           = $arguments['timeoutForMediumTests'] ?? 10;
1081
+		$arguments['timeoutForSmallTests']                            = $arguments['timeoutForSmallTests'] ?? 1;
1082
+		$arguments['verbose']                                         = $arguments['verbose'] ?? false;
1083
+	}
1084
+
1085
+	/**
1086
+	 * @param string $type
1087
+	 * @param string $message
1088
+	 */
1089
+	private function writeMessage($type, $message)
1090
+	{
1091
+		if (!$this->messagePrinted) {
1092
+			$this->write("\n");
1093
+		}
1094
+
1095
+		$this->write(
1096
+			\sprintf(
1097
+				"%-15s%s\n",
1098
+				$type . ':',
1099
+				$message
1100
+			)
1101
+		);
1102
+
1103
+		$this->messagePrinted = true;
1104
+	}
1105 1105
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/TextUI/Command.php 1 patch
Indentation   +950 added lines, -950 removed lines patch added patch discarded remove patch
@@ -43,985 +43,985 @@  discard block
 block discarded – undo
43 43
  */
44 44
 class Command
45 45
 {
46
-    /**
47
-     * @var array
48
-     */
49
-    protected $arguments = [
50
-        'listGroups'              => false,
51
-        'listSuites'              => false,
52
-        'listTests'               => false,
53
-        'listTestsXml'            => false,
54
-        'loader'                  => null,
55
-        'useDefaultConfiguration' => true,
56
-        'loadedExtensions'        => [],
57
-        'notLoadedExtensions'     => []
58
-    ];
59
-
60
-    /**
61
-     * @var array
62
-     */
63
-    protected $options = [];
64
-
65
-    /**
66
-     * @var array
67
-     */
68
-    protected $longOptions = [
69
-        'atleast-version='          => null,
70
-        'bootstrap='                => null,
71
-        'check-version'             => null,
72
-        'colors=='                  => null,
73
-        'columns='                  => null,
74
-        'configuration='            => null,
75
-        'coverage-clover='          => null,
76
-        'coverage-crap4j='          => null,
77
-        'coverage-html='            => null,
78
-        'coverage-php='             => null,
79
-        'coverage-text=='           => null,
80
-        'coverage-xml='             => null,
81
-        'debug'                     => null,
82
-        'disallow-test-output'      => null,
83
-        'disallow-resource-usage'   => null,
84
-        'disallow-todo-tests'       => null,
85
-        'enforce-time-limit'        => null,
86
-        'exclude-group='            => null,
87
-        'filter='                   => null,
88
-        'generate-configuration'    => null,
89
-        'globals-backup'            => null,
90
-        'group='                    => null,
91
-        'help'                      => null,
92
-        'include-path='             => null,
93
-        'list-groups'               => null,
94
-        'list-suites'               => null,
95
-        'list-tests'                => null,
96
-        'list-tests-xml='           => null,
97
-        'loader='                   => null,
98
-        'log-junit='                => null,
99
-        'log-teamcity='             => null,
100
-        'no-configuration'          => null,
101
-        'no-coverage'               => null,
102
-        'no-logging'                => null,
103
-        'no-extensions'             => null,
104
-        'printer='                  => null,
105
-        'process-isolation'         => null,
106
-        'repeat='                   => null,
107
-        'dont-report-useless-tests' => null,
108
-        'reverse-list'              => null,
109
-        'static-backup'             => null,
110
-        'stderr'                    => null,
111
-        'stop-on-error'             => null,
112
-        'stop-on-failure'           => null,
113
-        'stop-on-warning'           => null,
114
-        'stop-on-incomplete'        => null,
115
-        'stop-on-risky'             => null,
116
-        'stop-on-skipped'           => null,
117
-        'fail-on-warning'           => null,
118
-        'fail-on-risky'             => null,
119
-        'strict-coverage'           => null,
120
-        'disable-coverage-ignore'   => null,
121
-        'strict-global-state'       => null,
122
-        'teamcity'                  => null,
123
-        'testdox'                   => null,
124
-        'testdox-group='            => null,
125
-        'testdox-exclude-group='    => null,
126
-        'testdox-html='             => null,
127
-        'testdox-text='             => null,
128
-        'testdox-xml='              => null,
129
-        'test-suffix='              => null,
130
-        'testsuite='                => null,
131
-        'verbose'                   => null,
132
-        'version'                   => null,
133
-        'whitelist='                => null
134
-    ];
135
-
136
-    /**
137
-     * @var bool
138
-     */
139
-    private $versionStringPrinted = false;
140
-
141
-    /**
142
-     * @param bool $exit
143
-     */
144
-    public static function main($exit = true)
145
-    {
146
-        $command = new static;
147
-
148
-        return $command->run($_SERVER['argv'], $exit);
149
-    }
150
-
151
-    /**
152
-     * @param array $argv
153
-     * @param bool  $exit
154
-     *
155
-     * @return int
156
-     */
157
-    public function run(array $argv, $exit = true)
158
-    {
159
-        $this->handleArguments($argv);
160
-
161
-        $runner = $this->createRunner();
162
-
163
-        if ($this->arguments['test'] instanceof Test) {
164
-            $suite = $this->arguments['test'];
165
-        } else {
166
-            $suite = $runner->getTest(
167
-                $this->arguments['test'],
168
-                $this->arguments['testFile'],
169
-                $this->arguments['testSuffixes']
170
-            );
171
-        }
172
-
173
-        if ($this->arguments['listGroups']) {
174
-            return $this->handleListGroups($suite, $exit);
175
-        }
176
-
177
-        if ($this->arguments['listSuites']) {
178
-            return $this->handleListSuites($exit);
179
-        }
180
-
181
-        if ($this->arguments['listTests']) {
182
-            return $this->handleListTests($suite, $exit);
183
-        }
184
-
185
-        if ($this->arguments['listTestsXml']) {
186
-            return $this->handleListTestsXml($suite, $this->arguments['listTestsXml'], $exit);
187
-        }
188
-
189
-        unset(
190
-            $this->arguments['test'],
191
-            $this->arguments['testFile']
192
-        );
193
-
194
-        try {
195
-            $result = $runner->doRun($suite, $this->arguments, $exit);
196
-        } catch (Exception $e) {
197
-            print $e->getMessage() . PHP_EOL;
198
-        }
199
-
200
-        $return = TestRunner::FAILURE_EXIT;
201
-
202
-        if (isset($result) && $result->wasSuccessful()) {
203
-            $return = TestRunner::SUCCESS_EXIT;
204
-        } elseif (!isset($result) || $result->errorCount() > 0) {
205
-            $return = TestRunner::EXCEPTION_EXIT;
206
-        }
207
-
208
-        if ($exit) {
209
-            exit($return);
210
-        }
211
-
212
-        return $return;
213
-    }
214
-
215
-    /**
216
-     * Create a TestRunner, override in subclasses.
217
-     *
218
-     * @return TestRunner
219
-     */
220
-    protected function createRunner()
221
-    {
222
-        return new TestRunner($this->arguments['loader']);
223
-    }
224
-
225
-    /**
226
-     * Handles the command-line arguments.
227
-     *
228
-     * A child class of PHPUnit\TextUI\Command can hook into the argument
229
-     * parsing by adding the switch(es) to the $longOptions array and point to a
230
-     * callback method that handles the switch(es) in the child class like this
231
-     *
232
-     * <code>
233
-     * <?php
234
-     * class MyCommand extends PHPUnit\TextUI\Command
235
-     * {
236
-     *     public function __construct()
237
-     *     {
238
-     *         // my-switch won't accept a value, it's an on/off
239
-     *         $this->longOptions['my-switch'] = 'myHandler';
240
-     *         // my-secondswitch will accept a value - note the equals sign
241
-     *         $this->longOptions['my-secondswitch='] = 'myOtherHandler';
242
-     *     }
243
-     *
244
-     *     // --my-switch  -> myHandler()
245
-     *     protected function myHandler()
246
-     *     {
247
-     *     }
248
-     *
249
-     *     // --my-secondswitch foo -> myOtherHandler('foo')
250
-     *     protected function myOtherHandler ($value)
251
-     *     {
252
-     *     }
253
-     *
254
-     *     // You will also need this - the static keyword in the
255
-     *     // PHPUnit\TextUI\Command will mean that it'll be
256
-     *     // PHPUnit\TextUI\Command that gets instantiated,
257
-     *     // not MyCommand
258
-     *     public static function main($exit = true)
259
-     *     {
260
-     *         $command = new static;
261
-     *
262
-     *         return $command->run($_SERVER['argv'], $exit);
263
-     *     }
264
-     *
265
-     * }
266
-     * </code>
267
-     *
268
-     * @param array $argv
269
-     */
270
-    protected function handleArguments(array $argv)
271
-    {
272
-        try {
273
-            $this->options = Getopt::getopt(
274
-                $argv,
275
-                'd:c:hv',
276
-                \array_keys($this->longOptions)
277
-            );
278
-        } catch (Exception $t) {
279
-            $this->exitWithErrorMessage($t->getMessage());
280
-        }
281
-
282
-        foreach ($this->options[0] as $option) {
283
-            switch ($option[0]) {
284
-                case '--colors':
285
-                    $this->arguments['colors'] = $option[1] ?: ResultPrinter::COLOR_AUTO;
286
-
287
-                    break;
288
-
289
-                case '--bootstrap':
290
-                    $this->arguments['bootstrap'] = $option[1];
291
-
292
-                    break;
293
-
294
-                case '--columns':
295
-                    if (\is_numeric($option[1])) {
296
-                        $this->arguments['columns'] = (int) $option[1];
297
-                    } elseif ($option[1] === 'max') {
298
-                        $this->arguments['columns'] = 'max';
299
-                    }
300
-
301
-                    break;
302
-
303
-                case 'c':
304
-                case '--configuration':
305
-                    $this->arguments['configuration'] = $option[1];
306
-
307
-                    break;
308
-
309
-                case '--coverage-clover':
310
-                    $this->arguments['coverageClover'] = $option[1];
311
-
312
-                    break;
313
-
314
-                case '--coverage-crap4j':
315
-                    $this->arguments['coverageCrap4J'] = $option[1];
316
-
317
-                    break;
318
-
319
-                case '--coverage-html':
320
-                    $this->arguments['coverageHtml'] = $option[1];
321
-
322
-                    break;
323
-
324
-                case '--coverage-php':
325
-                    $this->arguments['coveragePHP'] = $option[1];
326
-
327
-                    break;
328
-
329
-                case '--coverage-text':
330
-                    if ($option[1] === null) {
331
-                        $option[1] = 'php://stdout';
332
-                    }
333
-
334
-                    $this->arguments['coverageText']                   = $option[1];
335
-                    $this->arguments['coverageTextShowUncoveredFiles'] = false;
336
-                    $this->arguments['coverageTextShowOnlySummary']    = false;
46
+	/**
47
+	 * @var array
48
+	 */
49
+	protected $arguments = [
50
+		'listGroups'              => false,
51
+		'listSuites'              => false,
52
+		'listTests'               => false,
53
+		'listTestsXml'            => false,
54
+		'loader'                  => null,
55
+		'useDefaultConfiguration' => true,
56
+		'loadedExtensions'        => [],
57
+		'notLoadedExtensions'     => []
58
+	];
59
+
60
+	/**
61
+	 * @var array
62
+	 */
63
+	protected $options = [];
64
+
65
+	/**
66
+	 * @var array
67
+	 */
68
+	protected $longOptions = [
69
+		'atleast-version='          => null,
70
+		'bootstrap='                => null,
71
+		'check-version'             => null,
72
+		'colors=='                  => null,
73
+		'columns='                  => null,
74
+		'configuration='            => null,
75
+		'coverage-clover='          => null,
76
+		'coverage-crap4j='          => null,
77
+		'coverage-html='            => null,
78
+		'coverage-php='             => null,
79
+		'coverage-text=='           => null,
80
+		'coverage-xml='             => null,
81
+		'debug'                     => null,
82
+		'disallow-test-output'      => null,
83
+		'disallow-resource-usage'   => null,
84
+		'disallow-todo-tests'       => null,
85
+		'enforce-time-limit'        => null,
86
+		'exclude-group='            => null,
87
+		'filter='                   => null,
88
+		'generate-configuration'    => null,
89
+		'globals-backup'            => null,
90
+		'group='                    => null,
91
+		'help'                      => null,
92
+		'include-path='             => null,
93
+		'list-groups'               => null,
94
+		'list-suites'               => null,
95
+		'list-tests'                => null,
96
+		'list-tests-xml='           => null,
97
+		'loader='                   => null,
98
+		'log-junit='                => null,
99
+		'log-teamcity='             => null,
100
+		'no-configuration'          => null,
101
+		'no-coverage'               => null,
102
+		'no-logging'                => null,
103
+		'no-extensions'             => null,
104
+		'printer='                  => null,
105
+		'process-isolation'         => null,
106
+		'repeat='                   => null,
107
+		'dont-report-useless-tests' => null,
108
+		'reverse-list'              => null,
109
+		'static-backup'             => null,
110
+		'stderr'                    => null,
111
+		'stop-on-error'             => null,
112
+		'stop-on-failure'           => null,
113
+		'stop-on-warning'           => null,
114
+		'stop-on-incomplete'        => null,
115
+		'stop-on-risky'             => null,
116
+		'stop-on-skipped'           => null,
117
+		'fail-on-warning'           => null,
118
+		'fail-on-risky'             => null,
119
+		'strict-coverage'           => null,
120
+		'disable-coverage-ignore'   => null,
121
+		'strict-global-state'       => null,
122
+		'teamcity'                  => null,
123
+		'testdox'                   => null,
124
+		'testdox-group='            => null,
125
+		'testdox-exclude-group='    => null,
126
+		'testdox-html='             => null,
127
+		'testdox-text='             => null,
128
+		'testdox-xml='              => null,
129
+		'test-suffix='              => null,
130
+		'testsuite='                => null,
131
+		'verbose'                   => null,
132
+		'version'                   => null,
133
+		'whitelist='                => null
134
+	];
135
+
136
+	/**
137
+	 * @var bool
138
+	 */
139
+	private $versionStringPrinted = false;
140
+
141
+	/**
142
+	 * @param bool $exit
143
+	 */
144
+	public static function main($exit = true)
145
+	{
146
+		$command = new static;
147
+
148
+		return $command->run($_SERVER['argv'], $exit);
149
+	}
150
+
151
+	/**
152
+	 * @param array $argv
153
+	 * @param bool  $exit
154
+	 *
155
+	 * @return int
156
+	 */
157
+	public function run(array $argv, $exit = true)
158
+	{
159
+		$this->handleArguments($argv);
160
+
161
+		$runner = $this->createRunner();
162
+
163
+		if ($this->arguments['test'] instanceof Test) {
164
+			$suite = $this->arguments['test'];
165
+		} else {
166
+			$suite = $runner->getTest(
167
+				$this->arguments['test'],
168
+				$this->arguments['testFile'],
169
+				$this->arguments['testSuffixes']
170
+			);
171
+		}
172
+
173
+		if ($this->arguments['listGroups']) {
174
+			return $this->handleListGroups($suite, $exit);
175
+		}
176
+
177
+		if ($this->arguments['listSuites']) {
178
+			return $this->handleListSuites($exit);
179
+		}
180
+
181
+		if ($this->arguments['listTests']) {
182
+			return $this->handleListTests($suite, $exit);
183
+		}
184
+
185
+		if ($this->arguments['listTestsXml']) {
186
+			return $this->handleListTestsXml($suite, $this->arguments['listTestsXml'], $exit);
187
+		}
188
+
189
+		unset(
190
+			$this->arguments['test'],
191
+			$this->arguments['testFile']
192
+		);
193
+
194
+		try {
195
+			$result = $runner->doRun($suite, $this->arguments, $exit);
196
+		} catch (Exception $e) {
197
+			print $e->getMessage() . PHP_EOL;
198
+		}
199
+
200
+		$return = TestRunner::FAILURE_EXIT;
201
+
202
+		if (isset($result) && $result->wasSuccessful()) {
203
+			$return = TestRunner::SUCCESS_EXIT;
204
+		} elseif (!isset($result) || $result->errorCount() > 0) {
205
+			$return = TestRunner::EXCEPTION_EXIT;
206
+		}
207
+
208
+		if ($exit) {
209
+			exit($return);
210
+		}
211
+
212
+		return $return;
213
+	}
214
+
215
+	/**
216
+	 * Create a TestRunner, override in subclasses.
217
+	 *
218
+	 * @return TestRunner
219
+	 */
220
+	protected function createRunner()
221
+	{
222
+		return new TestRunner($this->arguments['loader']);
223
+	}
224
+
225
+	/**
226
+	 * Handles the command-line arguments.
227
+	 *
228
+	 * A child class of PHPUnit\TextUI\Command can hook into the argument
229
+	 * parsing by adding the switch(es) to the $longOptions array and point to a
230
+	 * callback method that handles the switch(es) in the child class like this
231
+	 *
232
+	 * <code>
233
+	 * <?php
234
+	 * class MyCommand extends PHPUnit\TextUI\Command
235
+	 * {
236
+	 *     public function __construct()
237
+	 *     {
238
+	 *         // my-switch won't accept a value, it's an on/off
239
+	 *         $this->longOptions['my-switch'] = 'myHandler';
240
+	 *         // my-secondswitch will accept a value - note the equals sign
241
+	 *         $this->longOptions['my-secondswitch='] = 'myOtherHandler';
242
+	 *     }
243
+	 *
244
+	 *     // --my-switch  -> myHandler()
245
+	 *     protected function myHandler()
246
+	 *     {
247
+	 *     }
248
+	 *
249
+	 *     // --my-secondswitch foo -> myOtherHandler('foo')
250
+	 *     protected function myOtherHandler ($value)
251
+	 *     {
252
+	 *     }
253
+	 *
254
+	 *     // You will also need this - the static keyword in the
255
+	 *     // PHPUnit\TextUI\Command will mean that it'll be
256
+	 *     // PHPUnit\TextUI\Command that gets instantiated,
257
+	 *     // not MyCommand
258
+	 *     public static function main($exit = true)
259
+	 *     {
260
+	 *         $command = new static;
261
+	 *
262
+	 *         return $command->run($_SERVER['argv'], $exit);
263
+	 *     }
264
+	 *
265
+	 * }
266
+	 * </code>
267
+	 *
268
+	 * @param array $argv
269
+	 */
270
+	protected function handleArguments(array $argv)
271
+	{
272
+		try {
273
+			$this->options = Getopt::getopt(
274
+				$argv,
275
+				'd:c:hv',
276
+				\array_keys($this->longOptions)
277
+			);
278
+		} catch (Exception $t) {
279
+			$this->exitWithErrorMessage($t->getMessage());
280
+		}
281
+
282
+		foreach ($this->options[0] as $option) {
283
+			switch ($option[0]) {
284
+				case '--colors':
285
+					$this->arguments['colors'] = $option[1] ?: ResultPrinter::COLOR_AUTO;
286
+
287
+					break;
288
+
289
+				case '--bootstrap':
290
+					$this->arguments['bootstrap'] = $option[1];
291
+
292
+					break;
293
+
294
+				case '--columns':
295
+					if (\is_numeric($option[1])) {
296
+						$this->arguments['columns'] = (int) $option[1];
297
+					} elseif ($option[1] === 'max') {
298
+						$this->arguments['columns'] = 'max';
299
+					}
300
+
301
+					break;
302
+
303
+				case 'c':
304
+				case '--configuration':
305
+					$this->arguments['configuration'] = $option[1];
306
+
307
+					break;
308
+
309
+				case '--coverage-clover':
310
+					$this->arguments['coverageClover'] = $option[1];
311
+
312
+					break;
313
+
314
+				case '--coverage-crap4j':
315
+					$this->arguments['coverageCrap4J'] = $option[1];
316
+
317
+					break;
318
+
319
+				case '--coverage-html':
320
+					$this->arguments['coverageHtml'] = $option[1];
321
+
322
+					break;
323
+
324
+				case '--coverage-php':
325
+					$this->arguments['coveragePHP'] = $option[1];
326
+
327
+					break;
328
+
329
+				case '--coverage-text':
330
+					if ($option[1] === null) {
331
+						$option[1] = 'php://stdout';
332
+					}
333
+
334
+					$this->arguments['coverageText']                   = $option[1];
335
+					$this->arguments['coverageTextShowUncoveredFiles'] = false;
336
+					$this->arguments['coverageTextShowOnlySummary']    = false;
337 337
 
338
-                    break;
338
+					break;
339 339
 
340
-                case '--coverage-xml':
341
-                    $this->arguments['coverageXml'] = $option[1];
340
+				case '--coverage-xml':
341
+					$this->arguments['coverageXml'] = $option[1];
342 342
 
343
-                    break;
343
+					break;
344 344
 
345
-                case 'd':
346
-                    $ini = \explode('=', $option[1]);
345
+				case 'd':
346
+					$ini = \explode('=', $option[1]);
347 347
 
348
-                    if (isset($ini[0])) {
349
-                        if (isset($ini[1])) {
350
-                            \ini_set($ini[0], $ini[1]);
351
-                        } else {
352
-                            \ini_set($ini[0], true);
353
-                        }
354
-                    }
348
+					if (isset($ini[0])) {
349
+						if (isset($ini[1])) {
350
+							\ini_set($ini[0], $ini[1]);
351
+						} else {
352
+							\ini_set($ini[0], true);
353
+						}
354
+					}
355 355
 
356
-                    break;
356
+					break;
357 357
 
358
-                case '--debug':
359
-                    $this->arguments['debug'] = true;
358
+				case '--debug':
359
+					$this->arguments['debug'] = true;
360 360
 
361
-                    break;
361
+					break;
362 362
 
363
-                case 'h':
364
-                case '--help':
365
-                    $this->showHelp();
366
-                    exit(TestRunner::SUCCESS_EXIT);
363
+				case 'h':
364
+				case '--help':
365
+					$this->showHelp();
366
+					exit(TestRunner::SUCCESS_EXIT);
367 367
 
368
-                    break;
368
+					break;
369 369
 
370
-                case '--filter':
371
-                    $this->arguments['filter'] = $option[1];
370
+				case '--filter':
371
+					$this->arguments['filter'] = $option[1];
372 372
 
373
-                    break;
373
+					break;
374 374
 
375
-                case '--testsuite':
376
-                    $this->arguments['testsuite'] = $option[1];
375
+				case '--testsuite':
376
+					$this->arguments['testsuite'] = $option[1];
377 377
 
378
-                    break;
378
+					break;
379 379
 
380
-                case '--generate-configuration':
381
-                    $this->printVersionString();
380
+				case '--generate-configuration':
381
+					$this->printVersionString();
382 382
 
383
-                    print 'Generating phpunit.xml in ' . \getcwd() . PHP_EOL . PHP_EOL;
383
+					print 'Generating phpunit.xml in ' . \getcwd() . PHP_EOL . PHP_EOL;
384 384
 
385
-                    print 'Bootstrap script (relative to path shown above; default: vendor/autoload.php): ';
386
-                    $bootstrapScript = \trim(\fgets(STDIN));
385
+					print 'Bootstrap script (relative to path shown above; default: vendor/autoload.php): ';
386
+					$bootstrapScript = \trim(\fgets(STDIN));
387 387
 
388
-                    print 'Tests directory (relative to path shown above; default: tests): ';
389
-                    $testsDirectory = \trim(\fgets(STDIN));
388
+					print 'Tests directory (relative to path shown above; default: tests): ';
389
+					$testsDirectory = \trim(\fgets(STDIN));
390 390
 
391
-                    print 'Source directory (relative to path shown above; default: src): ';
392
-                    $src = \trim(\fgets(STDIN));
391
+					print 'Source directory (relative to path shown above; default: src): ';
392
+					$src = \trim(\fgets(STDIN));
393 393
 
394
-                    if ($bootstrapScript === '') {
395
-                        $bootstrapScript = 'vendor/autoload.php';
396
-                    }
394
+					if ($bootstrapScript === '') {
395
+						$bootstrapScript = 'vendor/autoload.php';
396
+					}
397 397
 
398
-                    if ($testsDirectory === '') {
399
-                        $testsDirectory = 'tests';
400
-                    }
398
+					if ($testsDirectory === '') {
399
+						$testsDirectory = 'tests';
400
+					}
401 401
 
402
-                    if ($src === '') {
403
-                        $src = 'src';
404
-                    }
402
+					if ($src === '') {
403
+						$src = 'src';
404
+					}
405 405
 
406
-                    $generator = new ConfigurationGenerator;
406
+					$generator = new ConfigurationGenerator;
407 407
 
408
-                    \file_put_contents(
409
-                        'phpunit.xml',
410
-                        $generator->generateDefaultConfiguration(
411
-                            Version::series(),
412
-                            $bootstrapScript,
413
-                            $testsDirectory,
414
-                            $src
415
-                        )
416
-                    );
408
+					\file_put_contents(
409
+						'phpunit.xml',
410
+						$generator->generateDefaultConfiguration(
411
+							Version::series(),
412
+							$bootstrapScript,
413
+							$testsDirectory,
414
+							$src
415
+						)
416
+					);
417 417
 
418
-                    print PHP_EOL . 'Generated phpunit.xml in ' . \getcwd() . PHP_EOL;
418
+					print PHP_EOL . 'Generated phpunit.xml in ' . \getcwd() . PHP_EOL;
419 419
 
420
-                    exit(TestRunner::SUCCESS_EXIT);
420
+					exit(TestRunner::SUCCESS_EXIT);
421 421
 
422
-                    break;
422
+					break;
423 423
 
424
-                case '--group':
425
-                    $this->arguments['groups'] = \explode(',', $option[1]);
424
+				case '--group':
425
+					$this->arguments['groups'] = \explode(',', $option[1]);
426 426
 
427
-                    break;
427
+					break;
428 428
 
429
-                case '--exclude-group':
430
-                    $this->arguments['excludeGroups'] = \explode(
431
-                        ',',
432
-                        $option[1]
433
-                    );
429
+				case '--exclude-group':
430
+					$this->arguments['excludeGroups'] = \explode(
431
+						',',
432
+						$option[1]
433
+					);
434 434
 
435
-                    break;
435
+					break;
436 436
 
437
-                case '--test-suffix':
438
-                    $this->arguments['testSuffixes'] = \explode(
439
-                        ',',
440
-                        $option[1]
441
-                    );
437
+				case '--test-suffix':
438
+					$this->arguments['testSuffixes'] = \explode(
439
+						',',
440
+						$option[1]
441
+					);
442 442
 
443
-                    break;
443
+					break;
444 444
 
445
-                case '--include-path':
446
-                    $includePath = $option[1];
445
+				case '--include-path':
446
+					$includePath = $option[1];
447 447
 
448
-                    break;
448
+					break;
449 449
 
450
-                case '--list-groups':
451
-                    $this->arguments['listGroups'] = true;
450
+				case '--list-groups':
451
+					$this->arguments['listGroups'] = true;
452 452
 
453
-                    break;
453
+					break;
454 454
 
455
-                case '--list-suites':
456
-                    $this->arguments['listSuites'] = true;
455
+				case '--list-suites':
456
+					$this->arguments['listSuites'] = true;
457 457
 
458
-                    break;
458
+					break;
459 459
 
460
-                case '--list-tests':
461
-                    $this->arguments['listTests'] = true;
460
+				case '--list-tests':
461
+					$this->arguments['listTests'] = true;
462 462
 
463
-                    break;
463
+					break;
464 464
 
465
-                case '--list-tests-xml':
466
-                    $this->arguments['listTestsXml'] = $option[1];
465
+				case '--list-tests-xml':
466
+					$this->arguments['listTestsXml'] = $option[1];
467 467
 
468
-                    break;
468
+					break;
469 469
 
470
-                case '--printer':
471
-                    $this->arguments['printer'] = $option[1];
470
+				case '--printer':
471
+					$this->arguments['printer'] = $option[1];
472 472
 
473
-                    break;
473
+					break;
474 474
 
475
-                case '--loader':
476
-                    $this->arguments['loader'] = $option[1];
475
+				case '--loader':
476
+					$this->arguments['loader'] = $option[1];
477 477
 
478
-                    break;
478
+					break;
479 479
 
480
-                case '--log-junit':
481
-                    $this->arguments['junitLogfile'] = $option[1];
480
+				case '--log-junit':
481
+					$this->arguments['junitLogfile'] = $option[1];
482 482
 
483
-                    break;
483
+					break;
484 484
 
485
-                case '--log-teamcity':
486
-                    $this->arguments['teamcityLogfile'] = $option[1];
485
+				case '--log-teamcity':
486
+					$this->arguments['teamcityLogfile'] = $option[1];
487 487
 
488
-                    break;
488
+					break;
489 489
 
490
-                case '--process-isolation':
491
-                    $this->arguments['processIsolation'] = true;
490
+				case '--process-isolation':
491
+					$this->arguments['processIsolation'] = true;
492 492
 
493
-                    break;
493
+					break;
494 494
 
495
-                case '--repeat':
496
-                    $this->arguments['repeat'] = (int) $option[1];
495
+				case '--repeat':
496
+					$this->arguments['repeat'] = (int) $option[1];
497 497
 
498
-                    break;
498
+					break;
499 499
 
500
-                case '--stderr':
501
-                    $this->arguments['stderr'] = true;
500
+				case '--stderr':
501
+					$this->arguments['stderr'] = true;
502 502
 
503
-                    break;
503
+					break;
504 504
 
505
-                case '--stop-on-error':
506
-                    $this->arguments['stopOnError'] = true;
505
+				case '--stop-on-error':
506
+					$this->arguments['stopOnError'] = true;
507 507
 
508
-                    break;
508
+					break;
509 509
 
510
-                case '--stop-on-failure':
511
-                    $this->arguments['stopOnFailure'] = true;
510
+				case '--stop-on-failure':
511
+					$this->arguments['stopOnFailure'] = true;
512 512
 
513
-                    break;
513
+					break;
514 514
 
515
-                case '--stop-on-warning':
516
-                    $this->arguments['stopOnWarning'] = true;
515
+				case '--stop-on-warning':
516
+					$this->arguments['stopOnWarning'] = true;
517 517
 
518
-                    break;
518
+					break;
519 519
 
520
-                case '--stop-on-incomplete':
521
-                    $this->arguments['stopOnIncomplete'] = true;
520
+				case '--stop-on-incomplete':
521
+					$this->arguments['stopOnIncomplete'] = true;
522 522
 
523
-                    break;
523
+					break;
524 524
 
525
-                case '--stop-on-risky':
526
-                    $this->arguments['stopOnRisky'] = true;
525
+				case '--stop-on-risky':
526
+					$this->arguments['stopOnRisky'] = true;
527 527
 
528
-                    break;
528
+					break;
529 529
 
530
-                case '--stop-on-skipped':
531
-                    $this->arguments['stopOnSkipped'] = true;
530
+				case '--stop-on-skipped':
531
+					$this->arguments['stopOnSkipped'] = true;
532 532
 
533
-                    break;
533
+					break;
534 534
 
535
-                case '--fail-on-warning':
536
-                    $this->arguments['failOnWarning'] = true;
535
+				case '--fail-on-warning':
536
+					$this->arguments['failOnWarning'] = true;
537 537
 
538
-                    break;
538
+					break;
539 539
 
540
-                case '--fail-on-risky':
541
-                    $this->arguments['failOnRisky'] = true;
540
+				case '--fail-on-risky':
541
+					$this->arguments['failOnRisky'] = true;
542 542
 
543
-                    break;
543
+					break;
544 544
 
545
-                case '--teamcity':
546
-                    $this->arguments['printer'] = TeamCity::class;
545
+				case '--teamcity':
546
+					$this->arguments['printer'] = TeamCity::class;
547 547
 
548
-                    break;
548
+					break;
549 549
 
550
-                case '--testdox':
551
-                    $this->arguments['printer'] = TextResultPrinter::class;
550
+				case '--testdox':
551
+					$this->arguments['printer'] = TextResultPrinter::class;
552 552
 
553
-                    break;
553
+					break;
554 554
 
555
-                case '--testdox-group':
556
-                    $this->arguments['testdoxGroups'] = \explode(
557
-                        ',',
558
-                        $option[1]
559
-                    );
555
+				case '--testdox-group':
556
+					$this->arguments['testdoxGroups'] = \explode(
557
+						',',
558
+						$option[1]
559
+					);
560 560
 
561
-                    break;
561
+					break;
562 562
 
563
-                case '--testdox-exclude-group':
564
-                    $this->arguments['testdoxExcludeGroups'] = \explode(
565
-                        ',',
566
-                        $option[1]
567
-                    );
563
+				case '--testdox-exclude-group':
564
+					$this->arguments['testdoxExcludeGroups'] = \explode(
565
+						',',
566
+						$option[1]
567
+					);
568 568
 
569
-                    break;
569
+					break;
570 570
 
571
-                case '--testdox-html':
572
-                    $this->arguments['testdoxHTMLFile'] = $option[1];
571
+				case '--testdox-html':
572
+					$this->arguments['testdoxHTMLFile'] = $option[1];
573 573
 
574
-                    break;
574
+					break;
575 575
 
576
-                case '--testdox-text':
577
-                    $this->arguments['testdoxTextFile'] = $option[1];
576
+				case '--testdox-text':
577
+					$this->arguments['testdoxTextFile'] = $option[1];
578 578
 
579
-                    break;
579
+					break;
580 580
 
581
-                case '--testdox-xml':
582
-                    $this->arguments['testdoxXMLFile'] = $option[1];
581
+				case '--testdox-xml':
582
+					$this->arguments['testdoxXMLFile'] = $option[1];
583 583
 
584
-                    break;
584
+					break;
585 585
 
586
-                case '--no-configuration':
587
-                    $this->arguments['useDefaultConfiguration'] = false;
586
+				case '--no-configuration':
587
+					$this->arguments['useDefaultConfiguration'] = false;
588 588
 
589
-                    break;
589
+					break;
590 590
 
591
-                case '--no-extensions':
592
-                    $this->arguments['noExtensions'] = true;
591
+				case '--no-extensions':
592
+					$this->arguments['noExtensions'] = true;
593 593
 
594
-                    break;
594
+					break;
595 595
 
596
-                case '--no-coverage':
597
-                    $this->arguments['noCoverage'] = true;
596
+				case '--no-coverage':
597
+					$this->arguments['noCoverage'] = true;
598 598
 
599
-                    break;
599
+					break;
600 600
 
601
-                case '--no-logging':
602
-                    $this->arguments['noLogging'] = true;
601
+				case '--no-logging':
602
+					$this->arguments['noLogging'] = true;
603 603
 
604
-                    break;
604
+					break;
605 605
 
606
-                case '--globals-backup':
607
-                    $this->arguments['backupGlobals'] = true;
606
+				case '--globals-backup':
607
+					$this->arguments['backupGlobals'] = true;
608 608
 
609
-                    break;
609
+					break;
610 610
 
611
-                case '--static-backup':
612
-                    $this->arguments['backupStaticAttributes'] = true;
611
+				case '--static-backup':
612
+					$this->arguments['backupStaticAttributes'] = true;
613 613
 
614
-                    break;
614
+					break;
615 615
 
616
-                case 'v':
617
-                case '--verbose':
618
-                    $this->arguments['verbose'] = true;
616
+				case 'v':
617
+				case '--verbose':
618
+					$this->arguments['verbose'] = true;
619 619
 
620
-                    break;
620
+					break;
621 621
 
622
-                case '--atleast-version':
623
-                    if (\version_compare(Version::id(), $option[1], '>=')) {
624
-                        exit(TestRunner::SUCCESS_EXIT);
625
-                    }
622
+				case '--atleast-version':
623
+					if (\version_compare(Version::id(), $option[1], '>=')) {
624
+						exit(TestRunner::SUCCESS_EXIT);
625
+					}
626 626
 
627
-                    exit(TestRunner::FAILURE_EXIT);
627
+					exit(TestRunner::FAILURE_EXIT);
628 628
 
629
-                    break;
629
+					break;
630 630
 
631
-                case '--version':
632
-                    $this->printVersionString();
633
-                    exit(TestRunner::SUCCESS_EXIT);
631
+				case '--version':
632
+					$this->printVersionString();
633
+					exit(TestRunner::SUCCESS_EXIT);
634 634
 
635
-                    break;
635
+					break;
636 636
 
637
-                case '--dont-report-useless-tests':
638
-                    $this->arguments['reportUselessTests'] = false;
637
+				case '--dont-report-useless-tests':
638
+					$this->arguments['reportUselessTests'] = false;
639 639
 
640
-                    break;
640
+					break;
641 641
 
642
-                case '--strict-coverage':
643
-                    $this->arguments['strictCoverage'] = true;
642
+				case '--strict-coverage':
643
+					$this->arguments['strictCoverage'] = true;
644 644
 
645
-                    break;
645
+					break;
646 646
 
647
-                case '--disable-coverage-ignore':
648
-                    $this->arguments['disableCodeCoverageIgnore'] = true;
647
+				case '--disable-coverage-ignore':
648
+					$this->arguments['disableCodeCoverageIgnore'] = true;
649 649
 
650
-                    break;
650
+					break;
651 651
 
652
-                case '--strict-global-state':
653
-                    $this->arguments['beStrictAboutChangesToGlobalState'] = true;
652
+				case '--strict-global-state':
653
+					$this->arguments['beStrictAboutChangesToGlobalState'] = true;
654 654
 
655
-                    break;
655
+					break;
656 656
 
657
-                case '--disallow-test-output':
658
-                    $this->arguments['disallowTestOutput'] = true;
657
+				case '--disallow-test-output':
658
+					$this->arguments['disallowTestOutput'] = true;
659 659
 
660
-                    break;
660
+					break;
661 661
 
662
-                case '--disallow-resource-usage':
663
-                    $this->arguments['beStrictAboutResourceUsageDuringSmallTests'] = true;
662
+				case '--disallow-resource-usage':
663
+					$this->arguments['beStrictAboutResourceUsageDuringSmallTests'] = true;
664 664
 
665
-                    break;
665
+					break;
666 666
 
667
-                case '--enforce-time-limit':
668
-                    $this->arguments['enforceTimeLimit'] = true;
667
+				case '--enforce-time-limit':
668
+					$this->arguments['enforceTimeLimit'] = true;
669 669
 
670
-                    break;
670
+					break;
671 671
 
672
-                case '--disallow-todo-tests':
673
-                    $this->arguments['disallowTodoAnnotatedTests'] = true;
672
+				case '--disallow-todo-tests':
673
+					$this->arguments['disallowTodoAnnotatedTests'] = true;
674 674
 
675
-                    break;
675
+					break;
676 676
 
677
-                case '--reverse-list':
678
-                    $this->arguments['reverseList'] = true;
677
+				case '--reverse-list':
678
+					$this->arguments['reverseList'] = true;
679 679
 
680
-                    break;
680
+					break;
681 681
 
682
-                case '--check-version':
683
-                    $this->handleVersionCheck();
682
+				case '--check-version':
683
+					$this->handleVersionCheck();
684 684
 
685
-                    break;
685
+					break;
686 686
 
687
-                case '--whitelist':
688
-                    $this->arguments['whitelist'] = $option[1];
687
+				case '--whitelist':
688
+					$this->arguments['whitelist'] = $option[1];
689 689
 
690
-                    break;
690
+					break;
691 691
 
692
-                default:
693
-                    $optionName = \str_replace('--', '', $option[0]);
692
+				default:
693
+					$optionName = \str_replace('--', '', $option[0]);
694 694
 
695
-                    $handler = null;
696
-                    if (isset($this->longOptions[$optionName])) {
697
-                        $handler = $this->longOptions[$optionName];
698
-                    } elseif (isset($this->longOptions[$optionName . '='])) {
699
-                        $handler = $this->longOptions[$optionName . '='];
700
-                    }
695
+					$handler = null;
696
+					if (isset($this->longOptions[$optionName])) {
697
+						$handler = $this->longOptions[$optionName];
698
+					} elseif (isset($this->longOptions[$optionName . '='])) {
699
+						$handler = $this->longOptions[$optionName . '='];
700
+					}
701 701
 
702
-                    if (isset($handler) && \is_callable([$this, $handler])) {
703
-                        $this->$handler($option[1]);
704
-                    }
705
-            }
706
-        }
702
+					if (isset($handler) && \is_callable([$this, $handler])) {
703
+						$this->$handler($option[1]);
704
+					}
705
+			}
706
+		}
707 707
 
708
-        $this->handleCustomTestSuite();
708
+		$this->handleCustomTestSuite();
709 709
 
710
-        if (!isset($this->arguments['test'])) {
711
-            if (isset($this->options[1][0])) {
712
-                $this->arguments['test'] = $this->options[1][0];
713
-            }
710
+		if (!isset($this->arguments['test'])) {
711
+			if (isset($this->options[1][0])) {
712
+				$this->arguments['test'] = $this->options[1][0];
713
+			}
714 714
 
715
-            if (isset($this->options[1][1])) {
716
-                $this->arguments['testFile'] = \realpath($this->options[1][1]);
717
-            } else {
718
-                $this->arguments['testFile'] = '';
719
-            }
715
+			if (isset($this->options[1][1])) {
716
+				$this->arguments['testFile'] = \realpath($this->options[1][1]);
717
+			} else {
718
+				$this->arguments['testFile'] = '';
719
+			}
720 720
 
721
-            if (isset($this->arguments['test']) &&
722
-                \is_file($this->arguments['test']) &&
723
-                \substr($this->arguments['test'], -5, 5) != '.phpt') {
724
-                $this->arguments['testFile'] = \realpath($this->arguments['test']);
725
-                $this->arguments['test']     = \substr($this->arguments['test'], 0, \strrpos($this->arguments['test'], '.'));
726
-            }
727
-        }
721
+			if (isset($this->arguments['test']) &&
722
+				\is_file($this->arguments['test']) &&
723
+				\substr($this->arguments['test'], -5, 5) != '.phpt') {
724
+				$this->arguments['testFile'] = \realpath($this->arguments['test']);
725
+				$this->arguments['test']     = \substr($this->arguments['test'], 0, \strrpos($this->arguments['test'], '.'));
726
+			}
727
+		}
728 728
 
729
-        if (!isset($this->arguments['testSuffixes'])) {
730
-            $this->arguments['testSuffixes'] = ['Test.php', '.phpt'];
731
-        }
729
+		if (!isset($this->arguments['testSuffixes'])) {
730
+			$this->arguments['testSuffixes'] = ['Test.php', '.phpt'];
731
+		}
732 732
 
733
-        if (isset($includePath)) {
734
-            \ini_set(
735
-                'include_path',
736
-                $includePath . PATH_SEPARATOR . \ini_get('include_path')
737
-            );
738
-        }
733
+		if (isset($includePath)) {
734
+			\ini_set(
735
+				'include_path',
736
+				$includePath . PATH_SEPARATOR . \ini_get('include_path')
737
+			);
738
+		}
739 739
 
740
-        if ($this->arguments['loader'] !== null) {
741
-            $this->arguments['loader'] = $this->handleLoader($this->arguments['loader']);
742
-        }
740
+		if ($this->arguments['loader'] !== null) {
741
+			$this->arguments['loader'] = $this->handleLoader($this->arguments['loader']);
742
+		}
743 743
 
744
-        if (isset($this->arguments['configuration']) &&
745
-            \is_dir($this->arguments['configuration'])) {
746
-            $configurationFile = $this->arguments['configuration'] . '/phpunit.xml';
747
-
748
-            if (\file_exists($configurationFile)) {
749
-                $this->arguments['configuration'] = \realpath(
750
-                    $configurationFile
751
-                );
752
-            } elseif (\file_exists($configurationFile . '.dist')) {
753
-                $this->arguments['configuration'] = \realpath(
754
-                    $configurationFile . '.dist'
755
-                );
756
-            }
757
-        } elseif (!isset($this->arguments['configuration']) &&
758
-            $this->arguments['useDefaultConfiguration']) {
759
-            if (\file_exists('phpunit.xml')) {
760
-                $this->arguments['configuration'] = \realpath('phpunit.xml');
761
-            } elseif (\file_exists('phpunit.xml.dist')) {
762
-                $this->arguments['configuration'] = \realpath(
763
-                    'phpunit.xml.dist'
764
-                );
765
-            }
766
-        }
767
-
768
-        if (isset($this->arguments['configuration'])) {
769
-            try {
770
-                $configuration = Configuration::getInstance(
771
-                    $this->arguments['configuration']
772
-                );
773
-            } catch (Throwable $t) {
774
-                print $t->getMessage() . PHP_EOL;
775
-                exit(TestRunner::FAILURE_EXIT);
776
-            }
777
-
778
-            $phpunitConfiguration = $configuration->getPHPUnitConfiguration();
779
-
780
-            $configuration->handlePHPConfiguration();
781
-
782
-            /*
744
+		if (isset($this->arguments['configuration']) &&
745
+			\is_dir($this->arguments['configuration'])) {
746
+			$configurationFile = $this->arguments['configuration'] . '/phpunit.xml';
747
+
748
+			if (\file_exists($configurationFile)) {
749
+				$this->arguments['configuration'] = \realpath(
750
+					$configurationFile
751
+				);
752
+			} elseif (\file_exists($configurationFile . '.dist')) {
753
+				$this->arguments['configuration'] = \realpath(
754
+					$configurationFile . '.dist'
755
+				);
756
+			}
757
+		} elseif (!isset($this->arguments['configuration']) &&
758
+			$this->arguments['useDefaultConfiguration']) {
759
+			if (\file_exists('phpunit.xml')) {
760
+				$this->arguments['configuration'] = \realpath('phpunit.xml');
761
+			} elseif (\file_exists('phpunit.xml.dist')) {
762
+				$this->arguments['configuration'] = \realpath(
763
+					'phpunit.xml.dist'
764
+				);
765
+			}
766
+		}
767
+
768
+		if (isset($this->arguments['configuration'])) {
769
+			try {
770
+				$configuration = Configuration::getInstance(
771
+					$this->arguments['configuration']
772
+				);
773
+			} catch (Throwable $t) {
774
+				print $t->getMessage() . PHP_EOL;
775
+				exit(TestRunner::FAILURE_EXIT);
776
+			}
777
+
778
+			$phpunitConfiguration = $configuration->getPHPUnitConfiguration();
779
+
780
+			$configuration->handlePHPConfiguration();
781
+
782
+			/*
783 783
              * Issue #1216
784 784
              */
785
-            if (isset($this->arguments['bootstrap'])) {
786
-                $this->handleBootstrap($this->arguments['bootstrap']);
787
-            } elseif (isset($phpunitConfiguration['bootstrap'])) {
788
-                $this->handleBootstrap($phpunitConfiguration['bootstrap']);
789
-            }
785
+			if (isset($this->arguments['bootstrap'])) {
786
+				$this->handleBootstrap($this->arguments['bootstrap']);
787
+			} elseif (isset($phpunitConfiguration['bootstrap'])) {
788
+				$this->handleBootstrap($phpunitConfiguration['bootstrap']);
789
+			}
790 790
 
791
-            /*
791
+			/*
792 792
              * Issue #657
793 793
              */
794
-            if (isset($phpunitConfiguration['stderr']) && !isset($this->arguments['stderr'])) {
795
-                $this->arguments['stderr'] = $phpunitConfiguration['stderr'];
796
-            }
797
-
798
-            if (isset($phpunitConfiguration['extensionsDirectory']) && !isset($this->arguments['noExtensions']) && \extension_loaded('phar')) {
799
-                $this->handleExtensions($phpunitConfiguration['extensionsDirectory']);
800
-            }
801
-
802
-            if (isset($phpunitConfiguration['columns']) && !isset($this->arguments['columns'])) {
803
-                $this->arguments['columns'] = $phpunitConfiguration['columns'];
804
-            }
805
-
806
-            if (!isset($this->arguments['printer']) && isset($phpunitConfiguration['printerClass'])) {
807
-                if (isset($phpunitConfiguration['printerFile'])) {
808
-                    $file = $phpunitConfiguration['printerFile'];
809
-                } else {
810
-                    $file = '';
811
-                }
812
-
813
-                $this->arguments['printer'] = $this->handlePrinter(
814
-                    $phpunitConfiguration['printerClass'],
815
-                    $file
816
-                );
817
-            }
818
-
819
-            if (isset($phpunitConfiguration['testSuiteLoaderClass'])) {
820
-                if (isset($phpunitConfiguration['testSuiteLoaderFile'])) {
821
-                    $file = $phpunitConfiguration['testSuiteLoaderFile'];
822
-                } else {
823
-                    $file = '';
824
-                }
825
-
826
-                $this->arguments['loader'] = $this->handleLoader(
827
-                    $phpunitConfiguration['testSuiteLoaderClass'],
828
-                    $file
829
-                );
830
-            }
831
-
832
-            if (!isset($this->arguments['testsuite']) && isset($phpunitConfiguration['defaultTestSuite'])) {
833
-                $this->arguments['testsuite'] = $phpunitConfiguration['defaultTestSuite'];
834
-            }
835
-
836
-            if (!isset($this->arguments['test'])) {
837
-                $testSuite = $configuration->getTestSuiteConfiguration($this->arguments['testsuite'] ?? null);
838
-
839
-                if ($testSuite !== null) {
840
-                    $this->arguments['test'] = $testSuite;
841
-                }
842
-            }
843
-        } elseif (isset($this->arguments['bootstrap'])) {
844
-            $this->handleBootstrap($this->arguments['bootstrap']);
845
-        }
846
-
847
-        if (isset($this->arguments['printer']) &&
848
-            \is_string($this->arguments['printer'])) {
849
-            $this->arguments['printer'] = $this->handlePrinter($this->arguments['printer']);
850
-        }
851
-
852
-        if (isset($this->arguments['test']) && \is_string($this->arguments['test']) && \substr($this->arguments['test'], -5, 5) == '.phpt') {
853
-            $test = new PhptTestCase($this->arguments['test']);
854
-
855
-            $this->arguments['test'] = new TestSuite;
856
-            $this->arguments['test']->addTest($test);
857
-        }
858
-
859
-        if (!isset($this->arguments['test'])) {
860
-            $this->showHelp();
861
-            exit(TestRunner::EXCEPTION_EXIT);
862
-        }
863
-    }
864
-
865
-    /**
866
-     * Handles the loading of the PHPUnit\Runner\TestSuiteLoader implementation.
867
-     *
868
-     * @param string $loaderClass
869
-     * @param string $loaderFile
870
-     *
871
-     * @return TestSuiteLoader|null
872
-     */
873
-    protected function handleLoader($loaderClass, $loaderFile = '')
874
-    {
875
-        if (!\class_exists($loaderClass, false)) {
876
-            if ($loaderFile == '') {
877
-                $loaderFile = Filesystem::classNameToFilename(
878
-                    $loaderClass
879
-                );
880
-            }
881
-
882
-            $loaderFile = \stream_resolve_include_path($loaderFile);
883
-
884
-            if ($loaderFile) {
885
-                require $loaderFile;
886
-            }
887
-        }
888
-
889
-        if (\class_exists($loaderClass, false)) {
890
-            $class = new ReflectionClass($loaderClass);
891
-
892
-            if ($class->implementsInterface(TestSuiteLoader::class) &&
893
-                $class->isInstantiable()) {
894
-                return $class->newInstance();
895
-            }
896
-        }
897
-
898
-        if ($loaderClass == StandardTestSuiteLoader::class) {
899
-            return;
900
-        }
901
-
902
-        $this->exitWithErrorMessage(
903
-            \sprintf(
904
-                'Could not use "%s" as loader.',
905
-                $loaderClass
906
-            )
907
-        );
908
-    }
909
-
910
-    /**
911
-     * Handles the loading of the PHPUnit\Util\Printer implementation.
912
-     *
913
-     * @param string $printerClass
914
-     * @param string $printerFile
915
-     *
916
-     * @return Printer|string|null
917
-     */
918
-    protected function handlePrinter($printerClass, $printerFile = '')
919
-    {
920
-        if (!\class_exists($printerClass, false)) {
921
-            if ($printerFile == '') {
922
-                $printerFile = Filesystem::classNameToFilename(
923
-                    $printerClass
924
-                );
925
-            }
926
-
927
-            $printerFile = \stream_resolve_include_path($printerFile);
928
-
929
-            if ($printerFile) {
930
-                require $printerFile;
931
-            }
932
-        }
933
-
934
-        if (!\class_exists($printerClass)) {
935
-            $this->exitWithErrorMessage(
936
-                \sprintf(
937
-                    'Could not use "%s" as printer: class does not exist',
938
-                    $printerClass
939
-                )
940
-            );
941
-        }
942
-
943
-        $class = new ReflectionClass($printerClass);
944
-
945
-        if (!$class->implementsInterface(TestListener::class)) {
946
-            $this->exitWithErrorMessage(
947
-                \sprintf(
948
-                    'Could not use "%s" as printer: class does not implement %s',
949
-                    $printerClass,
950
-                    TestListener::class
951
-                )
952
-            );
953
-        }
954
-
955
-        if (!$class->isSubclassOf(Printer::class)) {
956
-            $this->exitWithErrorMessage(
957
-                \sprintf(
958
-                    'Could not use "%s" as printer: class does not extend %s',
959
-                    $printerClass,
960
-                    Printer::class
961
-                )
962
-            );
963
-        }
964
-
965
-        if (!$class->isInstantiable()) {
966
-            $this->exitWithErrorMessage(
967
-                \sprintf(
968
-                    'Could not use "%s" as printer: class cannot be instantiated',
969
-                    $printerClass
970
-                )
971
-            );
972
-        }
973
-
974
-        if ($class->isSubclassOf(ResultPrinter::class)) {
975
-            return $printerClass;
976
-        }
977
-
978
-        $outputStream = isset($this->arguments['stderr']) ? 'php://stderr' : null;
979
-
980
-        return $class->newInstance($outputStream);
981
-    }
982
-
983
-    /**
984
-     * Loads a bootstrap file.
985
-     *
986
-     * @param string $filename
987
-     */
988
-    protected function handleBootstrap($filename)
989
-    {
990
-        try {
991
-            Fileloader::checkAndLoad($filename);
992
-        } catch (Exception $e) {
993
-            $this->exitWithErrorMessage($e->getMessage());
994
-        }
995
-    }
996
-
997
-    protected function handleVersionCheck()
998
-    {
999
-        $this->printVersionString();
1000
-
1001
-        $latestVersion = \file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit');
1002
-        $isOutdated    = \version_compare($latestVersion, Version::id(), '>');
1003
-
1004
-        if ($isOutdated) {
1005
-            \printf(
1006
-                'You are not using the latest version of PHPUnit.' . PHP_EOL .
1007
-                'The latest version is PHPUnit %s.' . PHP_EOL,
1008
-                $latestVersion
1009
-            );
1010
-        } else {
1011
-            print 'You are using the latest version of PHPUnit.' . PHP_EOL;
1012
-        }
1013
-
1014
-        exit(TestRunner::SUCCESS_EXIT);
1015
-    }
1016
-
1017
-    /**
1018
-     * Show the help message.
1019
-     */
1020
-    protected function showHelp()
1021
-    {
1022
-        $this->printVersionString();
1023
-
1024
-        print <<<EOT
794
+			if (isset($phpunitConfiguration['stderr']) && !isset($this->arguments['stderr'])) {
795
+				$this->arguments['stderr'] = $phpunitConfiguration['stderr'];
796
+			}
797
+
798
+			if (isset($phpunitConfiguration['extensionsDirectory']) && !isset($this->arguments['noExtensions']) && \extension_loaded('phar')) {
799
+				$this->handleExtensions($phpunitConfiguration['extensionsDirectory']);
800
+			}
801
+
802
+			if (isset($phpunitConfiguration['columns']) && !isset($this->arguments['columns'])) {
803
+				$this->arguments['columns'] = $phpunitConfiguration['columns'];
804
+			}
805
+
806
+			if (!isset($this->arguments['printer']) && isset($phpunitConfiguration['printerClass'])) {
807
+				if (isset($phpunitConfiguration['printerFile'])) {
808
+					$file = $phpunitConfiguration['printerFile'];
809
+				} else {
810
+					$file = '';
811
+				}
812
+
813
+				$this->arguments['printer'] = $this->handlePrinter(
814
+					$phpunitConfiguration['printerClass'],
815
+					$file
816
+				);
817
+			}
818
+
819
+			if (isset($phpunitConfiguration['testSuiteLoaderClass'])) {
820
+				if (isset($phpunitConfiguration['testSuiteLoaderFile'])) {
821
+					$file = $phpunitConfiguration['testSuiteLoaderFile'];
822
+				} else {
823
+					$file = '';
824
+				}
825
+
826
+				$this->arguments['loader'] = $this->handleLoader(
827
+					$phpunitConfiguration['testSuiteLoaderClass'],
828
+					$file
829
+				);
830
+			}
831
+
832
+			if (!isset($this->arguments['testsuite']) && isset($phpunitConfiguration['defaultTestSuite'])) {
833
+				$this->arguments['testsuite'] = $phpunitConfiguration['defaultTestSuite'];
834
+			}
835
+
836
+			if (!isset($this->arguments['test'])) {
837
+				$testSuite = $configuration->getTestSuiteConfiguration($this->arguments['testsuite'] ?? null);
838
+
839
+				if ($testSuite !== null) {
840
+					$this->arguments['test'] = $testSuite;
841
+				}
842
+			}
843
+		} elseif (isset($this->arguments['bootstrap'])) {
844
+			$this->handleBootstrap($this->arguments['bootstrap']);
845
+		}
846
+
847
+		if (isset($this->arguments['printer']) &&
848
+			\is_string($this->arguments['printer'])) {
849
+			$this->arguments['printer'] = $this->handlePrinter($this->arguments['printer']);
850
+		}
851
+
852
+		if (isset($this->arguments['test']) && \is_string($this->arguments['test']) && \substr($this->arguments['test'], -5, 5) == '.phpt') {
853
+			$test = new PhptTestCase($this->arguments['test']);
854
+
855
+			$this->arguments['test'] = new TestSuite;
856
+			$this->arguments['test']->addTest($test);
857
+		}
858
+
859
+		if (!isset($this->arguments['test'])) {
860
+			$this->showHelp();
861
+			exit(TestRunner::EXCEPTION_EXIT);
862
+		}
863
+	}
864
+
865
+	/**
866
+	 * Handles the loading of the PHPUnit\Runner\TestSuiteLoader implementation.
867
+	 *
868
+	 * @param string $loaderClass
869
+	 * @param string $loaderFile
870
+	 *
871
+	 * @return TestSuiteLoader|null
872
+	 */
873
+	protected function handleLoader($loaderClass, $loaderFile = '')
874
+	{
875
+		if (!\class_exists($loaderClass, false)) {
876
+			if ($loaderFile == '') {
877
+				$loaderFile = Filesystem::classNameToFilename(
878
+					$loaderClass
879
+				);
880
+			}
881
+
882
+			$loaderFile = \stream_resolve_include_path($loaderFile);
883
+
884
+			if ($loaderFile) {
885
+				require $loaderFile;
886
+			}
887
+		}
888
+
889
+		if (\class_exists($loaderClass, false)) {
890
+			$class = new ReflectionClass($loaderClass);
891
+
892
+			if ($class->implementsInterface(TestSuiteLoader::class) &&
893
+				$class->isInstantiable()) {
894
+				return $class->newInstance();
895
+			}
896
+		}
897
+
898
+		if ($loaderClass == StandardTestSuiteLoader::class) {
899
+			return;
900
+		}
901
+
902
+		$this->exitWithErrorMessage(
903
+			\sprintf(
904
+				'Could not use "%s" as loader.',
905
+				$loaderClass
906
+			)
907
+		);
908
+	}
909
+
910
+	/**
911
+	 * Handles the loading of the PHPUnit\Util\Printer implementation.
912
+	 *
913
+	 * @param string $printerClass
914
+	 * @param string $printerFile
915
+	 *
916
+	 * @return Printer|string|null
917
+	 */
918
+	protected function handlePrinter($printerClass, $printerFile = '')
919
+	{
920
+		if (!\class_exists($printerClass, false)) {
921
+			if ($printerFile == '') {
922
+				$printerFile = Filesystem::classNameToFilename(
923
+					$printerClass
924
+				);
925
+			}
926
+
927
+			$printerFile = \stream_resolve_include_path($printerFile);
928
+
929
+			if ($printerFile) {
930
+				require $printerFile;
931
+			}
932
+		}
933
+
934
+		if (!\class_exists($printerClass)) {
935
+			$this->exitWithErrorMessage(
936
+				\sprintf(
937
+					'Could not use "%s" as printer: class does not exist',
938
+					$printerClass
939
+				)
940
+			);
941
+		}
942
+
943
+		$class = new ReflectionClass($printerClass);
944
+
945
+		if (!$class->implementsInterface(TestListener::class)) {
946
+			$this->exitWithErrorMessage(
947
+				\sprintf(
948
+					'Could not use "%s" as printer: class does not implement %s',
949
+					$printerClass,
950
+					TestListener::class
951
+				)
952
+			);
953
+		}
954
+
955
+		if (!$class->isSubclassOf(Printer::class)) {
956
+			$this->exitWithErrorMessage(
957
+				\sprintf(
958
+					'Could not use "%s" as printer: class does not extend %s',
959
+					$printerClass,
960
+					Printer::class
961
+				)
962
+			);
963
+		}
964
+
965
+		if (!$class->isInstantiable()) {
966
+			$this->exitWithErrorMessage(
967
+				\sprintf(
968
+					'Could not use "%s" as printer: class cannot be instantiated',
969
+					$printerClass
970
+				)
971
+			);
972
+		}
973
+
974
+		if ($class->isSubclassOf(ResultPrinter::class)) {
975
+			return $printerClass;
976
+		}
977
+
978
+		$outputStream = isset($this->arguments['stderr']) ? 'php://stderr' : null;
979
+
980
+		return $class->newInstance($outputStream);
981
+	}
982
+
983
+	/**
984
+	 * Loads a bootstrap file.
985
+	 *
986
+	 * @param string $filename
987
+	 */
988
+	protected function handleBootstrap($filename)
989
+	{
990
+		try {
991
+			Fileloader::checkAndLoad($filename);
992
+		} catch (Exception $e) {
993
+			$this->exitWithErrorMessage($e->getMessage());
994
+		}
995
+	}
996
+
997
+	protected function handleVersionCheck()
998
+	{
999
+		$this->printVersionString();
1000
+
1001
+		$latestVersion = \file_get_contents('https://phar.phpunit.de/latest-version-of/phpunit');
1002
+		$isOutdated    = \version_compare($latestVersion, Version::id(), '>');
1003
+
1004
+		if ($isOutdated) {
1005
+			\printf(
1006
+				'You are not using the latest version of PHPUnit.' . PHP_EOL .
1007
+				'The latest version is PHPUnit %s.' . PHP_EOL,
1008
+				$latestVersion
1009
+			);
1010
+		} else {
1011
+			print 'You are using the latest version of PHPUnit.' . PHP_EOL;
1012
+		}
1013
+
1014
+		exit(TestRunner::SUCCESS_EXIT);
1015
+	}
1016
+
1017
+	/**
1018
+	 * Show the help message.
1019
+	 */
1020
+	protected function showHelp()
1021
+	{
1022
+		$this->printVersionString();
1023
+
1024
+		print <<<EOT
1025 1025
 Usage: phpunit [options] UnitTest [UnitTest.php]
1026 1026
        phpunit [options] <directory>
1027 1027
 
@@ -1116,161 +1116,161 @@  discard block
 block discarded – undo
1116 1116
   --check-version             Check whether PHPUnit is the latest version.
1117 1117
 
1118 1118
 EOT;
1119
-    }
1119
+	}
1120 1120
 
1121
-    /**
1122
-     * Custom callback for test suite discovery.
1123
-     */
1124
-    protected function handleCustomTestSuite()
1125
-    {
1126
-    }
1121
+	/**
1122
+	 * Custom callback for test suite discovery.
1123
+	 */
1124
+	protected function handleCustomTestSuite()
1125
+	{
1126
+	}
1127 1127
 
1128
-    private function printVersionString()
1129
-    {
1130
-        if ($this->versionStringPrinted) {
1131
-            return;
1132
-        }
1128
+	private function printVersionString()
1129
+	{
1130
+		if ($this->versionStringPrinted) {
1131
+			return;
1132
+		}
1133 1133
 
1134
-        print Version::getVersionString() . PHP_EOL . PHP_EOL;
1134
+		print Version::getVersionString() . PHP_EOL . PHP_EOL;
1135 1135
 
1136
-        $this->versionStringPrinted = true;
1137
-    }
1136
+		$this->versionStringPrinted = true;
1137
+	}
1138 1138
 
1139
-    /**
1140
-     * @param string $message
1141
-     */
1142
-    private function exitWithErrorMessage($message)
1143
-    {
1144
-        $this->printVersionString();
1139
+	/**
1140
+	 * @param string $message
1141
+	 */
1142
+	private function exitWithErrorMessage($message)
1143
+	{
1144
+		$this->printVersionString();
1145 1145
 
1146
-        print $message . PHP_EOL;
1146
+		print $message . PHP_EOL;
1147 1147
 
1148
-        exit(TestRunner::FAILURE_EXIT);
1149
-    }
1148
+		exit(TestRunner::FAILURE_EXIT);
1149
+	}
1150 1150
 
1151
-    /**
1152
-     * @param string $directory
1153
-     */
1154
-    private function handleExtensions($directory)
1155
-    {
1156
-        $facade = new File_Iterator_Facade;
1151
+	/**
1152
+	 * @param string $directory
1153
+	 */
1154
+	private function handleExtensions($directory)
1155
+	{
1156
+		$facade = new File_Iterator_Facade;
1157 1157
 
1158
-        foreach ($facade->getFilesAsArray($directory, '.phar') as $file) {
1159
-            if (!\file_exists('phar://' . $file . '/manifest.xml')) {
1160
-                $this->arguments['notLoadedExtensions'][] = $file . ' is not an extension for PHPUnit';
1158
+		foreach ($facade->getFilesAsArray($directory, '.phar') as $file) {
1159
+			if (!\file_exists('phar://' . $file . '/manifest.xml')) {
1160
+				$this->arguments['notLoadedExtensions'][] = $file . ' is not an extension for PHPUnit';
1161 1161
 
1162
-                continue;
1163
-            }
1162
+				continue;
1163
+			}
1164 1164
 
1165
-            try {
1166
-                $applicationName = new ApplicationName('phpunit/phpunit');
1167
-                $version         = new PharIoVersion(Version::series());
1168
-                $manifest        = ManifestLoader::fromFile('phar://' . $file . '/manifest.xml');
1165
+			try {
1166
+				$applicationName = new ApplicationName('phpunit/phpunit');
1167
+				$version         = new PharIoVersion(Version::series());
1168
+				$manifest        = ManifestLoader::fromFile('phar://' . $file . '/manifest.xml');
1169 1169
 
1170
-                if (!$manifest->isExtensionFor($applicationName)) {
1171
-                    $this->arguments['notLoadedExtensions'][] = $file . ' is not an extension for PHPUnit';
1170
+				if (!$manifest->isExtensionFor($applicationName)) {
1171
+					$this->arguments['notLoadedExtensions'][] = $file . ' is not an extension for PHPUnit';
1172 1172
 
1173
-                    continue;
1174
-                }
1173
+					continue;
1174
+				}
1175 1175
 
1176
-                if (!$manifest->isExtensionFor($applicationName, $version)) {
1177
-                    $this->arguments['notLoadedExtensions'][] = $file . ' is not compatible with this version of PHPUnit';
1176
+				if (!$manifest->isExtensionFor($applicationName, $version)) {
1177
+					$this->arguments['notLoadedExtensions'][] = $file . ' is not compatible with this version of PHPUnit';
1178 1178
 
1179
-                    continue;
1180
-                }
1181
-            } catch (ManifestException $e) {
1182
-                $this->arguments['notLoadedExtensions'][] = $file . ': ' . $e->getMessage();
1179
+					continue;
1180
+				}
1181
+			} catch (ManifestException $e) {
1182
+				$this->arguments['notLoadedExtensions'][] = $file . ': ' . $e->getMessage();
1183 1183
 
1184
-                continue;
1185
-            }
1184
+				continue;
1185
+			}
1186 1186
 
1187
-            require $file;
1187
+			require $file;
1188 1188
 
1189
-            $this->arguments['loadedExtensions'][] = $manifest->getName() . ' ' . $manifest->getVersion()->getVersionString();
1190
-        }
1191
-    }
1189
+			$this->arguments['loadedExtensions'][] = $manifest->getName() . ' ' . $manifest->getVersion()->getVersionString();
1190
+		}
1191
+	}
1192 1192
 
1193
-    private function handleListGroups(TestSuite $suite, bool $exit): int
1194
-    {
1195
-        $this->printVersionString();
1193
+	private function handleListGroups(TestSuite $suite, bool $exit): int
1194
+	{
1195
+		$this->printVersionString();
1196 1196
 
1197
-        print 'Available test group(s):' . PHP_EOL;
1197
+		print 'Available test group(s):' . PHP_EOL;
1198 1198
 
1199
-        $groups = $suite->getGroups();
1200
-        \sort($groups);
1199
+		$groups = $suite->getGroups();
1200
+		\sort($groups);
1201 1201
 
1202
-        foreach ($groups as $group) {
1203
-            \printf(
1204
-                ' - %s' . PHP_EOL,
1205
-                $group
1206
-            );
1207
-        }
1202
+		foreach ($groups as $group) {
1203
+			\printf(
1204
+				' - %s' . PHP_EOL,
1205
+				$group
1206
+			);
1207
+		}
1208 1208
 
1209
-        if ($exit) {
1210
-            exit(TestRunner::SUCCESS_EXIT);
1211
-        }
1209
+		if ($exit) {
1210
+			exit(TestRunner::SUCCESS_EXIT);
1211
+		}
1212 1212
 
1213
-        return TestRunner::SUCCESS_EXIT;
1214
-    }
1213
+		return TestRunner::SUCCESS_EXIT;
1214
+	}
1215 1215
 
1216
-    private function handleListSuites(bool $exit): int
1217
-    {
1218
-        $this->printVersionString();
1216
+	private function handleListSuites(bool $exit): int
1217
+	{
1218
+		$this->printVersionString();
1219 1219
 
1220
-        print 'Available test suite(s):' . PHP_EOL;
1220
+		print 'Available test suite(s):' . PHP_EOL;
1221 1221
 
1222
-        $configuration = Configuration::getInstance(
1223
-            $this->arguments['configuration']
1224
-        );
1222
+		$configuration = Configuration::getInstance(
1223
+			$this->arguments['configuration']
1224
+		);
1225 1225
 
1226
-        $suiteNames = $configuration->getTestSuiteNames();
1226
+		$suiteNames = $configuration->getTestSuiteNames();
1227 1227
 
1228
-        foreach ($suiteNames as $suiteName) {
1229
-            \printf(
1230
-                ' - %s' . PHP_EOL,
1231
-                $suiteName
1232
-            );
1233
-        }
1228
+		foreach ($suiteNames as $suiteName) {
1229
+			\printf(
1230
+				' - %s' . PHP_EOL,
1231
+				$suiteName
1232
+			);
1233
+		}
1234 1234
 
1235
-        if ($exit) {
1236
-            exit(TestRunner::SUCCESS_EXIT);
1237
-        }
1235
+		if ($exit) {
1236
+			exit(TestRunner::SUCCESS_EXIT);
1237
+		}
1238 1238
 
1239
-        return TestRunner::SUCCESS_EXIT;
1240
-    }
1239
+		return TestRunner::SUCCESS_EXIT;
1240
+	}
1241 1241
 
1242
-    private function handleListTests(TestSuite $suite, bool $exit): int
1243
-    {
1244
-        $this->printVersionString();
1242
+	private function handleListTests(TestSuite $suite, bool $exit): int
1243
+	{
1244
+		$this->printVersionString();
1245 1245
 
1246
-        $renderer = new TextTestListRenderer;
1246
+		$renderer = new TextTestListRenderer;
1247 1247
 
1248
-        print $renderer->render($suite);
1248
+		print $renderer->render($suite);
1249 1249
 
1250
-        if ($exit) {
1251
-            exit(TestRunner::SUCCESS_EXIT);
1252
-        }
1250
+		if ($exit) {
1251
+			exit(TestRunner::SUCCESS_EXIT);
1252
+		}
1253 1253
 
1254
-        return TestRunner::SUCCESS_EXIT;
1255
-    }
1254
+		return TestRunner::SUCCESS_EXIT;
1255
+	}
1256 1256
 
1257
-    private function handleListTestsXml(TestSuite $suite, string $target, bool $exit): int
1258
-    {
1259
-        $this->printVersionString();
1257
+	private function handleListTestsXml(TestSuite $suite, string $target, bool $exit): int
1258
+	{
1259
+		$this->printVersionString();
1260 1260
 
1261
-        $renderer = new XmlTestListRenderer;
1261
+		$renderer = new XmlTestListRenderer;
1262 1262
 
1263
-        \file_put_contents($target, $renderer->render($suite));
1263
+		\file_put_contents($target, $renderer->render($suite));
1264 1264
 
1265
-        \printf(
1266
-            'Wrote list of tests that would have been run to %s' . \PHP_EOL,
1267
-            $target
1268
-        );
1265
+		\printf(
1266
+			'Wrote list of tests that would have been run to %s' . \PHP_EOL,
1267
+			$target
1268
+		);
1269 1269
 
1270
-        if ($exit) {
1271
-            exit(TestRunner::SUCCESS_EXIT);
1272
-        }
1270
+		if ($exit) {
1271
+			exit(TestRunner::SUCCESS_EXIT);
1272
+		}
1273 1273
 
1274
-        return TestRunner::SUCCESS_EXIT;
1275
-    }
1274
+		return TestRunner::SUCCESS_EXIT;
1275
+	}
1276 1276
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php 1 patch
Indentation   +660 added lines, -660 removed lines patch added patch discarded remove patch
@@ -30,664 +30,664 @@
 block discarded – undo
30 30
  */
31 31
 class ResultPrinter extends Printer implements TestListener
32 32
 {
33
-    const EVENT_TEST_START      = 0;
34
-    const EVENT_TEST_END        = 1;
35
-    const EVENT_TESTSUITE_START = 2;
36
-    const EVENT_TESTSUITE_END   = 3;
37
-
38
-    const COLOR_NEVER   = 'never';
39
-    const COLOR_AUTO    = 'auto';
40
-    const COLOR_ALWAYS  = 'always';
41
-    const COLOR_DEFAULT = self::COLOR_NEVER;
42
-
43
-    /**
44
-     * @var array
45
-     */
46
-    private static $ansiCodes = [
47
-        'bold'       => 1,
48
-        'fg-black'   => 30,
49
-        'fg-red'     => 31,
50
-        'fg-green'   => 32,
51
-        'fg-yellow'  => 33,
52
-        'fg-blue'    => 34,
53
-        'fg-magenta' => 35,
54
-        'fg-cyan'    => 36,
55
-        'fg-white'   => 37,
56
-        'bg-black'   => 40,
57
-        'bg-red'     => 41,
58
-        'bg-green'   => 42,
59
-        'bg-yellow'  => 43,
60
-        'bg-blue'    => 44,
61
-        'bg-magenta' => 45,
62
-        'bg-cyan'    => 46,
63
-        'bg-white'   => 47
64
-    ];
65
-
66
-    /**
67
-     * @var int
68
-     */
69
-    protected $column = 0;
70
-
71
-    /**
72
-     * @var int
73
-     */
74
-    protected $maxColumn;
75
-
76
-    /**
77
-     * @var bool
78
-     */
79
-    protected $lastTestFailed = false;
80
-
81
-    /**
82
-     * @var int
83
-     */
84
-    protected $numAssertions = 0;
85
-
86
-    /**
87
-     * @var int
88
-     */
89
-    protected $numTests = -1;
90
-
91
-    /**
92
-     * @var int
93
-     */
94
-    protected $numTestsRun = 0;
95
-
96
-    /**
97
-     * @var int
98
-     */
99
-    protected $numTestsWidth;
100
-
101
-    /**
102
-     * @var bool
103
-     */
104
-    protected $colors = false;
105
-
106
-    /**
107
-     * @var bool
108
-     */
109
-    protected $debug = false;
110
-
111
-    /**
112
-     * @var bool
113
-     */
114
-    protected $verbose = false;
115
-
116
-    /**
117
-     * @var int
118
-     */
119
-    private $numberOfColumns;
120
-
121
-    /**
122
-     * @var bool
123
-     */
124
-    private $reverse;
125
-
126
-    /**
127
-     * @var bool
128
-     */
129
-    private $defectListPrinted = false;
130
-
131
-    /**
132
-     * Constructor.
133
-     *
134
-     * @param mixed      $out
135
-     * @param bool       $verbose
136
-     * @param string     $colors
137
-     * @param bool       $debug
138
-     * @param int|string $numberOfColumns
139
-     * @param bool       $reverse
140
-     *
141
-     * @throws Exception
142
-     */
143
-    public function __construct($out = null, $verbose = false, $colors = self::COLOR_DEFAULT, $debug = false, $numberOfColumns = 80, $reverse = false)
144
-    {
145
-        parent::__construct($out);
146
-
147
-        if (!\is_bool($verbose)) {
148
-            throw InvalidArgumentHelper::factory(2, 'boolean');
149
-        }
150
-
151
-        $availableColors = [self::COLOR_NEVER, self::COLOR_AUTO, self::COLOR_ALWAYS];
152
-
153
-        if (!\in_array($colors, $availableColors)) {
154
-            throw InvalidArgumentHelper::factory(
155
-                3,
156
-                \vsprintf('value from "%s", "%s" or "%s"', $availableColors)
157
-            );
158
-        }
159
-
160
-        if (!\is_bool($debug)) {
161
-            throw InvalidArgumentHelper::factory(4, 'boolean');
162
-        }
163
-
164
-        if (!\is_int($numberOfColumns) && $numberOfColumns !== 'max') {
165
-            throw InvalidArgumentHelper::factory(5, 'integer or "max"');
166
-        }
167
-
168
-        if (!\is_bool($reverse)) {
169
-            throw InvalidArgumentHelper::factory(6, 'boolean');
170
-        }
171
-
172
-        $console            = new Console;
173
-        $maxNumberOfColumns = $console->getNumberOfColumns();
174
-
175
-        if ($numberOfColumns === 'max' || ($numberOfColumns !== 80 && $numberOfColumns > $maxNumberOfColumns)) {
176
-            $numberOfColumns = $maxNumberOfColumns;
177
-        }
178
-
179
-        $this->numberOfColumns = $numberOfColumns;
180
-        $this->verbose         = $verbose;
181
-        $this->debug           = $debug;
182
-        $this->reverse         = $reverse;
183
-
184
-        if ($colors === self::COLOR_AUTO && $console->hasColorSupport()) {
185
-            $this->colors = true;
186
-        } else {
187
-            $this->colors = (self::COLOR_ALWAYS === $colors);
188
-        }
189
-    }
190
-
191
-    /**
192
-     * @param TestResult $result
193
-     */
194
-    public function printResult(TestResult $result)
195
-    {
196
-        $this->printHeader();
197
-        $this->printErrors($result);
198
-        $this->printWarnings($result);
199
-        $this->printFailures($result);
200
-        $this->printRisky($result);
201
-
202
-        if ($this->verbose) {
203
-            $this->printIncompletes($result);
204
-            $this->printSkipped($result);
205
-        }
206
-
207
-        $this->printFooter($result);
208
-    }
209
-
210
-    /**
211
-     * @param array  $defects
212
-     * @param string $type
213
-     */
214
-    protected function printDefects(array $defects, $type)
215
-    {
216
-        $count = \count($defects);
217
-
218
-        if ($count == 0) {
219
-            return;
220
-        }
221
-
222
-        if ($this->defectListPrinted) {
223
-            $this->write("\n--\n\n");
224
-        }
225
-
226
-        $this->write(
227
-            \sprintf(
228
-                "There %s %d %s%s:\n",
229
-                ($count == 1) ? 'was' : 'were',
230
-                $count,
231
-                $type,
232
-                ($count == 1) ? '' : 's'
233
-            )
234
-        );
235
-
236
-        $i = 1;
237
-
238
-        if ($this->reverse) {
239
-            $defects = \array_reverse($defects);
240
-        }
241
-
242
-        foreach ($defects as $defect) {
243
-            $this->printDefect($defect, $i++);
244
-        }
245
-
246
-        $this->defectListPrinted = true;
247
-    }
248
-
249
-    /**
250
-     * @param TestFailure $defect
251
-     * @param int         $count
252
-     */
253
-    protected function printDefect(TestFailure $defect, $count)
254
-    {
255
-        $this->printDefectHeader($defect, $count);
256
-        $this->printDefectTrace($defect);
257
-    }
258
-
259
-    /**
260
-     * @param TestFailure $defect
261
-     * @param int         $count
262
-     */
263
-    protected function printDefectHeader(TestFailure $defect, $count)
264
-    {
265
-        $this->write(
266
-            \sprintf(
267
-                "\n%d) %s\n",
268
-                $count,
269
-                $defect->getTestName()
270
-            )
271
-        );
272
-    }
273
-
274
-    /**
275
-     * @param TestFailure $defect
276
-     */
277
-    protected function printDefectTrace(TestFailure $defect)
278
-    {
279
-        $e = $defect->thrownException();
280
-        $this->write((string) $e);
281
-
282
-        while ($e = $e->getPrevious()) {
283
-            $this->write("\nCaused by\n" . $e);
284
-        }
285
-    }
286
-
287
-    /**
288
-     * @param TestResult $result
289
-     */
290
-    protected function printErrors(TestResult $result)
291
-    {
292
-        $this->printDefects($result->errors(), 'error');
293
-    }
294
-
295
-    /**
296
-     * @param TestResult $result
297
-     */
298
-    protected function printFailures(TestResult $result)
299
-    {
300
-        $this->printDefects($result->failures(), 'failure');
301
-    }
302
-
303
-    /**
304
-     * @param TestResult $result
305
-     */
306
-    protected function printWarnings(TestResult $result)
307
-    {
308
-        $this->printDefects($result->warnings(), 'warning');
309
-    }
310
-
311
-    /**
312
-     * @param TestResult $result
313
-     */
314
-    protected function printIncompletes(TestResult $result)
315
-    {
316
-        $this->printDefects($result->notImplemented(), 'incomplete test');
317
-    }
318
-
319
-    /**
320
-     * @param TestResult $result
321
-     */
322
-    protected function printRisky(TestResult $result)
323
-    {
324
-        $this->printDefects($result->risky(), 'risky test');
325
-    }
326
-
327
-    /**
328
-     * @param TestResult $result
329
-     */
330
-    protected function printSkipped(TestResult $result)
331
-    {
332
-        $this->printDefects($result->skipped(), 'skipped test');
333
-    }
334
-
335
-    protected function printHeader()
336
-    {
337
-        $this->write("\n\n" . PHP_Timer::resourceUsage() . "\n\n");
338
-    }
339
-
340
-    /**
341
-     * @param TestResult $result
342
-     */
343
-    protected function printFooter(TestResult $result)
344
-    {
345
-        if (\count($result) === 0) {
346
-            $this->writeWithColor(
347
-                'fg-black, bg-yellow',
348
-                'No tests executed!'
349
-            );
350
-
351
-            return;
352
-        }
353
-
354
-        if ($result->wasSuccessful() &&
355
-            $result->allHarmless() &&
356
-            $result->allCompletelyImplemented() &&
357
-            $result->noneSkipped()) {
358
-            $this->writeWithColor(
359
-                'fg-black, bg-green',
360
-                \sprintf(
361
-                    'OK (%d test%s, %d assertion%s)',
362
-                    \count($result),
363
-                    (\count($result) == 1) ? '' : 's',
364
-                    $this->numAssertions,
365
-                    ($this->numAssertions == 1) ? '' : 's'
366
-                )
367
-            );
368
-        } else {
369
-            if ($result->wasSuccessful()) {
370
-                $color = 'fg-black, bg-yellow';
371
-
372
-                if ($this->verbose || !$result->allHarmless()) {
373
-                    $this->write("\n");
374
-                }
375
-
376
-                $this->writeWithColor(
377
-                    $color,
378
-                    'OK, but incomplete, skipped, or risky tests!'
379
-                );
380
-            } else {
381
-                $this->write("\n");
382
-
383
-                if ($result->errorCount()) {
384
-                    $color = 'fg-white, bg-red';
385
-
386
-                    $this->writeWithColor(
387
-                        $color,
388
-                        'ERRORS!'
389
-                    );
390
-                } elseif ($result->failureCount()) {
391
-                    $color = 'fg-white, bg-red';
392
-
393
-                    $this->writeWithColor(
394
-                        $color,
395
-                        'FAILURES!'
396
-                    );
397
-                } elseif ($result->warningCount()) {
398
-                    $color = 'fg-black, bg-yellow';
399
-
400
-                    $this->writeWithColor(
401
-                        $color,
402
-                        'WARNINGS!'
403
-                    );
404
-                }
405
-            }
406
-
407
-            $this->writeCountString(\count($result), 'Tests', $color, true);
408
-            $this->writeCountString($this->numAssertions, 'Assertions', $color, true);
409
-            $this->writeCountString($result->errorCount(), 'Errors', $color);
410
-            $this->writeCountString($result->failureCount(), 'Failures', $color);
411
-            $this->writeCountString($result->warningCount(), 'Warnings', $color);
412
-            $this->writeCountString($result->skippedCount(), 'Skipped', $color);
413
-            $this->writeCountString($result->notImplementedCount(), 'Incomplete', $color);
414
-            $this->writeCountString($result->riskyCount(), 'Risky', $color);
415
-            $this->writeWithColor($color, '.', true);
416
-        }
417
-    }
418
-
419
-    public function printWaitPrompt()
420
-    {
421
-        $this->write("\n<RETURN> to continue\n");
422
-    }
423
-
424
-    /**
425
-     * An error occurred.
426
-     *
427
-     * @param Test       $test
428
-     * @param \Exception $e
429
-     * @param float      $time
430
-     */
431
-    public function addError(Test $test, \Exception $e, $time)
432
-    {
433
-        $this->writeProgressWithColor('fg-red, bold', 'E');
434
-        $this->lastTestFailed = true;
435
-    }
436
-
437
-    /**
438
-     * A failure occurred.
439
-     *
440
-     * @param Test                 $test
441
-     * @param AssertionFailedError $e
442
-     * @param float                $time
443
-     */
444
-    public function addFailure(Test $test, AssertionFailedError $e, $time)
445
-    {
446
-        $this->writeProgressWithColor('bg-red, fg-white', 'F');
447
-        $this->lastTestFailed = true;
448
-    }
449
-
450
-    /**
451
-     * A warning occurred.
452
-     *
453
-     * @param Test    $test
454
-     * @param Warning $e
455
-     * @param float   $time
456
-     */
457
-    public function addWarning(Test $test, Warning $e, $time)
458
-    {
459
-        $this->writeProgressWithColor('fg-yellow, bold', 'W');
460
-        $this->lastTestFailed = true;
461
-    }
462
-
463
-    /**
464
-     * Incomplete test.
465
-     *
466
-     * @param Test       $test
467
-     * @param \Exception $e
468
-     * @param float      $time
469
-     */
470
-    public function addIncompleteTest(Test $test, \Exception $e, $time)
471
-    {
472
-        $this->writeProgressWithColor('fg-yellow, bold', 'I');
473
-        $this->lastTestFailed = true;
474
-    }
475
-
476
-    /**
477
-     * Risky test.
478
-     *
479
-     * @param Test       $test
480
-     * @param \Exception $e
481
-     * @param float      $time
482
-     */
483
-    public function addRiskyTest(Test $test, \Exception $e, $time)
484
-    {
485
-        $this->writeProgressWithColor('fg-yellow, bold', 'R');
486
-        $this->lastTestFailed = true;
487
-    }
488
-
489
-    /**
490
-     * Skipped test.
491
-     *
492
-     * @param Test       $test
493
-     * @param \Exception $e
494
-     * @param float      $time
495
-     */
496
-    public function addSkippedTest(Test $test, \Exception $e, $time)
497
-    {
498
-        $this->writeProgressWithColor('fg-cyan, bold', 'S');
499
-        $this->lastTestFailed = true;
500
-    }
501
-
502
-    /**
503
-     * A testsuite started.
504
-     *
505
-     * @param TestSuite $suite
506
-     */
507
-    public function startTestSuite(TestSuite $suite)
508
-    {
509
-        if ($this->numTests == -1) {
510
-            $this->numTests      = \count($suite);
511
-            $this->numTestsWidth = \strlen((string) $this->numTests);
512
-            $this->maxColumn     = $this->numberOfColumns - \strlen('  /  (XXX%)') - (2 * $this->numTestsWidth);
513
-        }
514
-    }
515
-
516
-    /**
517
-     * A testsuite ended.
518
-     *
519
-     * @param TestSuite $suite
520
-     */
521
-    public function endTestSuite(TestSuite $suite)
522
-    {
523
-    }
524
-
525
-    /**
526
-     * A test started.
527
-     *
528
-     * @param Test $test
529
-     */
530
-    public function startTest(Test $test)
531
-    {
532
-        if ($this->debug) {
533
-            $this->write(
534
-                \sprintf(
535
-                    "\nStarting test '%s'.\n",
536
-                    \PHPUnit\Util\Test::describe($test)
537
-                )
538
-            );
539
-        }
540
-    }
541
-
542
-    /**
543
-     * A test ended.
544
-     *
545
-     * @param Test  $test
546
-     * @param float $time
547
-     */
548
-    public function endTest(Test $test, $time)
549
-    {
550
-        if (!$this->lastTestFailed) {
551
-            $this->writeProgress('.');
552
-        }
553
-
554
-        if ($test instanceof TestCase) {
555
-            $this->numAssertions += $test->getNumAssertions();
556
-        } elseif ($test instanceof PhptTestCase) {
557
-            $this->numAssertions++;
558
-        }
559
-
560
-        $this->lastTestFailed = false;
561
-
562
-        if ($test instanceof TestCase) {
563
-            if (!$test->hasExpectationOnOutput()) {
564
-                $this->write($test->getActualOutput());
565
-            }
566
-        }
567
-    }
568
-
569
-    /**
570
-     * @param string $progress
571
-     */
572
-    protected function writeProgress($progress)
573
-    {
574
-        $this->write($progress);
575
-        $this->column++;
576
-        $this->numTestsRun++;
577
-
578
-        if ($this->column == $this->maxColumn || $this->numTestsRun == $this->numTests) {
579
-            if ($this->numTestsRun == $this->numTests) {
580
-                $this->write(\str_repeat(' ', $this->maxColumn - $this->column));
581
-            }
582
-
583
-            $this->write(
584
-                \sprintf(
585
-                    ' %' . $this->numTestsWidth . 'd / %' .
586
-                    $this->numTestsWidth . 'd (%3s%%)',
587
-                    $this->numTestsRun,
588
-                    $this->numTests,
589
-                    \floor(($this->numTestsRun / $this->numTests) * 100)
590
-                )
591
-            );
592
-
593
-            if ($this->column == $this->maxColumn) {
594
-                $this->writeNewLine();
595
-            }
596
-        }
597
-    }
598
-
599
-    protected function writeNewLine()
600
-    {
601
-        $this->column = 0;
602
-        $this->write("\n");
603
-    }
604
-
605
-    /**
606
-     * Formats a buffer with a specified ANSI color sequence if colors are
607
-     * enabled.
608
-     *
609
-     * @param string $color
610
-     * @param string $buffer
611
-     *
612
-     * @return string
613
-     */
614
-    protected function formatWithColor($color, $buffer)
615
-    {
616
-        if (!$this->colors) {
617
-            return $buffer;
618
-        }
619
-
620
-        $codes   = \array_map('trim', \explode(',', $color));
621
-        $lines   = \explode("\n", $buffer);
622
-        $padding = \max(\array_map('strlen', $lines));
623
-        $styles  = [];
624
-
625
-        foreach ($codes as $code) {
626
-            $styles[] = self::$ansiCodes[$code];
627
-        }
628
-
629
-        $style = \sprintf("\x1b[%sm", \implode(';', $styles));
630
-
631
-        $styledLines = [];
632
-
633
-        foreach ($lines as $line) {
634
-            $styledLines[] = $style . \str_pad($line, $padding) . "\x1b[0m";
635
-        }
636
-
637
-        return \implode("\n", $styledLines);
638
-    }
639
-
640
-    /**
641
-     * Writes a buffer out with a color sequence if colors are enabled.
642
-     *
643
-     * @param string $color
644
-     * @param string $buffer
645
-     * @param bool   $lf
646
-     */
647
-    protected function writeWithColor($color, $buffer, $lf = true)
648
-    {
649
-        $this->write($this->formatWithColor($color, $buffer));
650
-
651
-        if ($lf) {
652
-            $this->write("\n");
653
-        }
654
-    }
655
-
656
-    /**
657
-     * Writes progress with a color sequence if colors are enabled.
658
-     *
659
-     * @param string $color
660
-     * @param string $buffer
661
-     */
662
-    protected function writeProgressWithColor($color, $buffer)
663
-    {
664
-        $buffer = $this->formatWithColor($color, $buffer);
665
-        $this->writeProgress($buffer);
666
-    }
667
-
668
-    /**
669
-     * @param int    $count
670
-     * @param string $name
671
-     * @param string $color
672
-     * @param bool   $always
673
-     */
674
-    private function writeCountString($count, $name, $color, $always = false)
675
-    {
676
-        static $first = true;
677
-
678
-        if ($always || $count > 0) {
679
-            $this->writeWithColor(
680
-                $color,
681
-                \sprintf(
682
-                    '%s%s: %d',
683
-                    !$first ? ', ' : '',
684
-                    $name,
685
-                    $count
686
-                ),
687
-                false
688
-            );
689
-
690
-            $first = false;
691
-        }
692
-    }
33
+	const EVENT_TEST_START      = 0;
34
+	const EVENT_TEST_END        = 1;
35
+	const EVENT_TESTSUITE_START = 2;
36
+	const EVENT_TESTSUITE_END   = 3;
37
+
38
+	const COLOR_NEVER   = 'never';
39
+	const COLOR_AUTO    = 'auto';
40
+	const COLOR_ALWAYS  = 'always';
41
+	const COLOR_DEFAULT = self::COLOR_NEVER;
42
+
43
+	/**
44
+	 * @var array
45
+	 */
46
+	private static $ansiCodes = [
47
+		'bold'       => 1,
48
+		'fg-black'   => 30,
49
+		'fg-red'     => 31,
50
+		'fg-green'   => 32,
51
+		'fg-yellow'  => 33,
52
+		'fg-blue'    => 34,
53
+		'fg-magenta' => 35,
54
+		'fg-cyan'    => 36,
55
+		'fg-white'   => 37,
56
+		'bg-black'   => 40,
57
+		'bg-red'     => 41,
58
+		'bg-green'   => 42,
59
+		'bg-yellow'  => 43,
60
+		'bg-blue'    => 44,
61
+		'bg-magenta' => 45,
62
+		'bg-cyan'    => 46,
63
+		'bg-white'   => 47
64
+	];
65
+
66
+	/**
67
+	 * @var int
68
+	 */
69
+	protected $column = 0;
70
+
71
+	/**
72
+	 * @var int
73
+	 */
74
+	protected $maxColumn;
75
+
76
+	/**
77
+	 * @var bool
78
+	 */
79
+	protected $lastTestFailed = false;
80
+
81
+	/**
82
+	 * @var int
83
+	 */
84
+	protected $numAssertions = 0;
85
+
86
+	/**
87
+	 * @var int
88
+	 */
89
+	protected $numTests = -1;
90
+
91
+	/**
92
+	 * @var int
93
+	 */
94
+	protected $numTestsRun = 0;
95
+
96
+	/**
97
+	 * @var int
98
+	 */
99
+	protected $numTestsWidth;
100
+
101
+	/**
102
+	 * @var bool
103
+	 */
104
+	protected $colors = false;
105
+
106
+	/**
107
+	 * @var bool
108
+	 */
109
+	protected $debug = false;
110
+
111
+	/**
112
+	 * @var bool
113
+	 */
114
+	protected $verbose = false;
115
+
116
+	/**
117
+	 * @var int
118
+	 */
119
+	private $numberOfColumns;
120
+
121
+	/**
122
+	 * @var bool
123
+	 */
124
+	private $reverse;
125
+
126
+	/**
127
+	 * @var bool
128
+	 */
129
+	private $defectListPrinted = false;
130
+
131
+	/**
132
+	 * Constructor.
133
+	 *
134
+	 * @param mixed      $out
135
+	 * @param bool       $verbose
136
+	 * @param string     $colors
137
+	 * @param bool       $debug
138
+	 * @param int|string $numberOfColumns
139
+	 * @param bool       $reverse
140
+	 *
141
+	 * @throws Exception
142
+	 */
143
+	public function __construct($out = null, $verbose = false, $colors = self::COLOR_DEFAULT, $debug = false, $numberOfColumns = 80, $reverse = false)
144
+	{
145
+		parent::__construct($out);
146
+
147
+		if (!\is_bool($verbose)) {
148
+			throw InvalidArgumentHelper::factory(2, 'boolean');
149
+		}
150
+
151
+		$availableColors = [self::COLOR_NEVER, self::COLOR_AUTO, self::COLOR_ALWAYS];
152
+
153
+		if (!\in_array($colors, $availableColors)) {
154
+			throw InvalidArgumentHelper::factory(
155
+				3,
156
+				\vsprintf('value from "%s", "%s" or "%s"', $availableColors)
157
+			);
158
+		}
159
+
160
+		if (!\is_bool($debug)) {
161
+			throw InvalidArgumentHelper::factory(4, 'boolean');
162
+		}
163
+
164
+		if (!\is_int($numberOfColumns) && $numberOfColumns !== 'max') {
165
+			throw InvalidArgumentHelper::factory(5, 'integer or "max"');
166
+		}
167
+
168
+		if (!\is_bool($reverse)) {
169
+			throw InvalidArgumentHelper::factory(6, 'boolean');
170
+		}
171
+
172
+		$console            = new Console;
173
+		$maxNumberOfColumns = $console->getNumberOfColumns();
174
+
175
+		if ($numberOfColumns === 'max' || ($numberOfColumns !== 80 && $numberOfColumns > $maxNumberOfColumns)) {
176
+			$numberOfColumns = $maxNumberOfColumns;
177
+		}
178
+
179
+		$this->numberOfColumns = $numberOfColumns;
180
+		$this->verbose         = $verbose;
181
+		$this->debug           = $debug;
182
+		$this->reverse         = $reverse;
183
+
184
+		if ($colors === self::COLOR_AUTO && $console->hasColorSupport()) {
185
+			$this->colors = true;
186
+		} else {
187
+			$this->colors = (self::COLOR_ALWAYS === $colors);
188
+		}
189
+	}
190
+
191
+	/**
192
+	 * @param TestResult $result
193
+	 */
194
+	public function printResult(TestResult $result)
195
+	{
196
+		$this->printHeader();
197
+		$this->printErrors($result);
198
+		$this->printWarnings($result);
199
+		$this->printFailures($result);
200
+		$this->printRisky($result);
201
+
202
+		if ($this->verbose) {
203
+			$this->printIncompletes($result);
204
+			$this->printSkipped($result);
205
+		}
206
+
207
+		$this->printFooter($result);
208
+	}
209
+
210
+	/**
211
+	 * @param array  $defects
212
+	 * @param string $type
213
+	 */
214
+	protected function printDefects(array $defects, $type)
215
+	{
216
+		$count = \count($defects);
217
+
218
+		if ($count == 0) {
219
+			return;
220
+		}
221
+
222
+		if ($this->defectListPrinted) {
223
+			$this->write("\n--\n\n");
224
+		}
225
+
226
+		$this->write(
227
+			\sprintf(
228
+				"There %s %d %s%s:\n",
229
+				($count == 1) ? 'was' : 'were',
230
+				$count,
231
+				$type,
232
+				($count == 1) ? '' : 's'
233
+			)
234
+		);
235
+
236
+		$i = 1;
237
+
238
+		if ($this->reverse) {
239
+			$defects = \array_reverse($defects);
240
+		}
241
+
242
+		foreach ($defects as $defect) {
243
+			$this->printDefect($defect, $i++);
244
+		}
245
+
246
+		$this->defectListPrinted = true;
247
+	}
248
+
249
+	/**
250
+	 * @param TestFailure $defect
251
+	 * @param int         $count
252
+	 */
253
+	protected function printDefect(TestFailure $defect, $count)
254
+	{
255
+		$this->printDefectHeader($defect, $count);
256
+		$this->printDefectTrace($defect);
257
+	}
258
+
259
+	/**
260
+	 * @param TestFailure $defect
261
+	 * @param int         $count
262
+	 */
263
+	protected function printDefectHeader(TestFailure $defect, $count)
264
+	{
265
+		$this->write(
266
+			\sprintf(
267
+				"\n%d) %s\n",
268
+				$count,
269
+				$defect->getTestName()
270
+			)
271
+		);
272
+	}
273
+
274
+	/**
275
+	 * @param TestFailure $defect
276
+	 */
277
+	protected function printDefectTrace(TestFailure $defect)
278
+	{
279
+		$e = $defect->thrownException();
280
+		$this->write((string) $e);
281
+
282
+		while ($e = $e->getPrevious()) {
283
+			$this->write("\nCaused by\n" . $e);
284
+		}
285
+	}
286
+
287
+	/**
288
+	 * @param TestResult $result
289
+	 */
290
+	protected function printErrors(TestResult $result)
291
+	{
292
+		$this->printDefects($result->errors(), 'error');
293
+	}
294
+
295
+	/**
296
+	 * @param TestResult $result
297
+	 */
298
+	protected function printFailures(TestResult $result)
299
+	{
300
+		$this->printDefects($result->failures(), 'failure');
301
+	}
302
+
303
+	/**
304
+	 * @param TestResult $result
305
+	 */
306
+	protected function printWarnings(TestResult $result)
307
+	{
308
+		$this->printDefects($result->warnings(), 'warning');
309
+	}
310
+
311
+	/**
312
+	 * @param TestResult $result
313
+	 */
314
+	protected function printIncompletes(TestResult $result)
315
+	{
316
+		$this->printDefects($result->notImplemented(), 'incomplete test');
317
+	}
318
+
319
+	/**
320
+	 * @param TestResult $result
321
+	 */
322
+	protected function printRisky(TestResult $result)
323
+	{
324
+		$this->printDefects($result->risky(), 'risky test');
325
+	}
326
+
327
+	/**
328
+	 * @param TestResult $result
329
+	 */
330
+	protected function printSkipped(TestResult $result)
331
+	{
332
+		$this->printDefects($result->skipped(), 'skipped test');
333
+	}
334
+
335
+	protected function printHeader()
336
+	{
337
+		$this->write("\n\n" . PHP_Timer::resourceUsage() . "\n\n");
338
+	}
339
+
340
+	/**
341
+	 * @param TestResult $result
342
+	 */
343
+	protected function printFooter(TestResult $result)
344
+	{
345
+		if (\count($result) === 0) {
346
+			$this->writeWithColor(
347
+				'fg-black, bg-yellow',
348
+				'No tests executed!'
349
+			);
350
+
351
+			return;
352
+		}
353
+
354
+		if ($result->wasSuccessful() &&
355
+			$result->allHarmless() &&
356
+			$result->allCompletelyImplemented() &&
357
+			$result->noneSkipped()) {
358
+			$this->writeWithColor(
359
+				'fg-black, bg-green',
360
+				\sprintf(
361
+					'OK (%d test%s, %d assertion%s)',
362
+					\count($result),
363
+					(\count($result) == 1) ? '' : 's',
364
+					$this->numAssertions,
365
+					($this->numAssertions == 1) ? '' : 's'
366
+				)
367
+			);
368
+		} else {
369
+			if ($result->wasSuccessful()) {
370
+				$color = 'fg-black, bg-yellow';
371
+
372
+				if ($this->verbose || !$result->allHarmless()) {
373
+					$this->write("\n");
374
+				}
375
+
376
+				$this->writeWithColor(
377
+					$color,
378
+					'OK, but incomplete, skipped, or risky tests!'
379
+				);
380
+			} else {
381
+				$this->write("\n");
382
+
383
+				if ($result->errorCount()) {
384
+					$color = 'fg-white, bg-red';
385
+
386
+					$this->writeWithColor(
387
+						$color,
388
+						'ERRORS!'
389
+					);
390
+				} elseif ($result->failureCount()) {
391
+					$color = 'fg-white, bg-red';
392
+
393
+					$this->writeWithColor(
394
+						$color,
395
+						'FAILURES!'
396
+					);
397
+				} elseif ($result->warningCount()) {
398
+					$color = 'fg-black, bg-yellow';
399
+
400
+					$this->writeWithColor(
401
+						$color,
402
+						'WARNINGS!'
403
+					);
404
+				}
405
+			}
406
+
407
+			$this->writeCountString(\count($result), 'Tests', $color, true);
408
+			$this->writeCountString($this->numAssertions, 'Assertions', $color, true);
409
+			$this->writeCountString($result->errorCount(), 'Errors', $color);
410
+			$this->writeCountString($result->failureCount(), 'Failures', $color);
411
+			$this->writeCountString($result->warningCount(), 'Warnings', $color);
412
+			$this->writeCountString($result->skippedCount(), 'Skipped', $color);
413
+			$this->writeCountString($result->notImplementedCount(), 'Incomplete', $color);
414
+			$this->writeCountString($result->riskyCount(), 'Risky', $color);
415
+			$this->writeWithColor($color, '.', true);
416
+		}
417
+	}
418
+
419
+	public function printWaitPrompt()
420
+	{
421
+		$this->write("\n<RETURN> to continue\n");
422
+	}
423
+
424
+	/**
425
+	 * An error occurred.
426
+	 *
427
+	 * @param Test       $test
428
+	 * @param \Exception $e
429
+	 * @param float      $time
430
+	 */
431
+	public function addError(Test $test, \Exception $e, $time)
432
+	{
433
+		$this->writeProgressWithColor('fg-red, bold', 'E');
434
+		$this->lastTestFailed = true;
435
+	}
436
+
437
+	/**
438
+	 * A failure occurred.
439
+	 *
440
+	 * @param Test                 $test
441
+	 * @param AssertionFailedError $e
442
+	 * @param float                $time
443
+	 */
444
+	public function addFailure(Test $test, AssertionFailedError $e, $time)
445
+	{
446
+		$this->writeProgressWithColor('bg-red, fg-white', 'F');
447
+		$this->lastTestFailed = true;
448
+	}
449
+
450
+	/**
451
+	 * A warning occurred.
452
+	 *
453
+	 * @param Test    $test
454
+	 * @param Warning $e
455
+	 * @param float   $time
456
+	 */
457
+	public function addWarning(Test $test, Warning $e, $time)
458
+	{
459
+		$this->writeProgressWithColor('fg-yellow, bold', 'W');
460
+		$this->lastTestFailed = true;
461
+	}
462
+
463
+	/**
464
+	 * Incomplete test.
465
+	 *
466
+	 * @param Test       $test
467
+	 * @param \Exception $e
468
+	 * @param float      $time
469
+	 */
470
+	public function addIncompleteTest(Test $test, \Exception $e, $time)
471
+	{
472
+		$this->writeProgressWithColor('fg-yellow, bold', 'I');
473
+		$this->lastTestFailed = true;
474
+	}
475
+
476
+	/**
477
+	 * Risky test.
478
+	 *
479
+	 * @param Test       $test
480
+	 * @param \Exception $e
481
+	 * @param float      $time
482
+	 */
483
+	public function addRiskyTest(Test $test, \Exception $e, $time)
484
+	{
485
+		$this->writeProgressWithColor('fg-yellow, bold', 'R');
486
+		$this->lastTestFailed = true;
487
+	}
488
+
489
+	/**
490
+	 * Skipped test.
491
+	 *
492
+	 * @param Test       $test
493
+	 * @param \Exception $e
494
+	 * @param float      $time
495
+	 */
496
+	public function addSkippedTest(Test $test, \Exception $e, $time)
497
+	{
498
+		$this->writeProgressWithColor('fg-cyan, bold', 'S');
499
+		$this->lastTestFailed = true;
500
+	}
501
+
502
+	/**
503
+	 * A testsuite started.
504
+	 *
505
+	 * @param TestSuite $suite
506
+	 */
507
+	public function startTestSuite(TestSuite $suite)
508
+	{
509
+		if ($this->numTests == -1) {
510
+			$this->numTests      = \count($suite);
511
+			$this->numTestsWidth = \strlen((string) $this->numTests);
512
+			$this->maxColumn     = $this->numberOfColumns - \strlen('  /  (XXX%)') - (2 * $this->numTestsWidth);
513
+		}
514
+	}
515
+
516
+	/**
517
+	 * A testsuite ended.
518
+	 *
519
+	 * @param TestSuite $suite
520
+	 */
521
+	public function endTestSuite(TestSuite $suite)
522
+	{
523
+	}
524
+
525
+	/**
526
+	 * A test started.
527
+	 *
528
+	 * @param Test $test
529
+	 */
530
+	public function startTest(Test $test)
531
+	{
532
+		if ($this->debug) {
533
+			$this->write(
534
+				\sprintf(
535
+					"\nStarting test '%s'.\n",
536
+					\PHPUnit\Util\Test::describe($test)
537
+				)
538
+			);
539
+		}
540
+	}
541
+
542
+	/**
543
+	 * A test ended.
544
+	 *
545
+	 * @param Test  $test
546
+	 * @param float $time
547
+	 */
548
+	public function endTest(Test $test, $time)
549
+	{
550
+		if (!$this->lastTestFailed) {
551
+			$this->writeProgress('.');
552
+		}
553
+
554
+		if ($test instanceof TestCase) {
555
+			$this->numAssertions += $test->getNumAssertions();
556
+		} elseif ($test instanceof PhptTestCase) {
557
+			$this->numAssertions++;
558
+		}
559
+
560
+		$this->lastTestFailed = false;
561
+
562
+		if ($test instanceof TestCase) {
563
+			if (!$test->hasExpectationOnOutput()) {
564
+				$this->write($test->getActualOutput());
565
+			}
566
+		}
567
+	}
568
+
569
+	/**
570
+	 * @param string $progress
571
+	 */
572
+	protected function writeProgress($progress)
573
+	{
574
+		$this->write($progress);
575
+		$this->column++;
576
+		$this->numTestsRun++;
577
+
578
+		if ($this->column == $this->maxColumn || $this->numTestsRun == $this->numTests) {
579
+			if ($this->numTestsRun == $this->numTests) {
580
+				$this->write(\str_repeat(' ', $this->maxColumn - $this->column));
581
+			}
582
+
583
+			$this->write(
584
+				\sprintf(
585
+					' %' . $this->numTestsWidth . 'd / %' .
586
+					$this->numTestsWidth . 'd (%3s%%)',
587
+					$this->numTestsRun,
588
+					$this->numTests,
589
+					\floor(($this->numTestsRun / $this->numTests) * 100)
590
+				)
591
+			);
592
+
593
+			if ($this->column == $this->maxColumn) {
594
+				$this->writeNewLine();
595
+			}
596
+		}
597
+	}
598
+
599
+	protected function writeNewLine()
600
+	{
601
+		$this->column = 0;
602
+		$this->write("\n");
603
+	}
604
+
605
+	/**
606
+	 * Formats a buffer with a specified ANSI color sequence if colors are
607
+	 * enabled.
608
+	 *
609
+	 * @param string $color
610
+	 * @param string $buffer
611
+	 *
612
+	 * @return string
613
+	 */
614
+	protected function formatWithColor($color, $buffer)
615
+	{
616
+		if (!$this->colors) {
617
+			return $buffer;
618
+		}
619
+
620
+		$codes   = \array_map('trim', \explode(',', $color));
621
+		$lines   = \explode("\n", $buffer);
622
+		$padding = \max(\array_map('strlen', $lines));
623
+		$styles  = [];
624
+
625
+		foreach ($codes as $code) {
626
+			$styles[] = self::$ansiCodes[$code];
627
+		}
628
+
629
+		$style = \sprintf("\x1b[%sm", \implode(';', $styles));
630
+
631
+		$styledLines = [];
632
+
633
+		foreach ($lines as $line) {
634
+			$styledLines[] = $style . \str_pad($line, $padding) . "\x1b[0m";
635
+		}
636
+
637
+		return \implode("\n", $styledLines);
638
+	}
639
+
640
+	/**
641
+	 * Writes a buffer out with a color sequence if colors are enabled.
642
+	 *
643
+	 * @param string $color
644
+	 * @param string $buffer
645
+	 * @param bool   $lf
646
+	 */
647
+	protected function writeWithColor($color, $buffer, $lf = true)
648
+	{
649
+		$this->write($this->formatWithColor($color, $buffer));
650
+
651
+		if ($lf) {
652
+			$this->write("\n");
653
+		}
654
+	}
655
+
656
+	/**
657
+	 * Writes progress with a color sequence if colors are enabled.
658
+	 *
659
+	 * @param string $color
660
+	 * @param string $buffer
661
+	 */
662
+	protected function writeProgressWithColor($color, $buffer)
663
+	{
664
+		$buffer = $this->formatWithColor($color, $buffer);
665
+		$this->writeProgress($buffer);
666
+	}
667
+
668
+	/**
669
+	 * @param int    $count
670
+	 * @param string $name
671
+	 * @param string $color
672
+	 * @param bool   $always
673
+	 */
674
+	private function writeCountString($count, $name, $color, $always = false)
675
+	{
676
+		static $first = true;
677
+
678
+		if ($always || $count > 0) {
679
+			$this->writeWithColor(
680
+				$color,
681
+				\sprintf(
682
+					'%s%s: %d',
683
+					!$first ? ', ' : '',
684
+					$name,
685
+					$count
686
+				),
687
+				false
688
+			);
689
+
690
+			$first = false;
691
+		}
692
+	}
693 693
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/Test.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@
 block discarded – undo
17 17
  */
18 18
 interface Test extends Countable
19 19
 {
20
-    /**
21
-     * Runs a test and collects its result in a TestResult instance.
22
-     *
23
-     * @param TestResult $result
24
-     *
25
-     * @return TestResult
26
-     */
27
-    public function run(TestResult $result = null);
20
+	/**
21
+	 * Runs a test and collects its result in a TestResult instance.
22
+	 *
23
+	 * @param TestResult $result
24
+	 *
25
+	 * @return TestResult
26
+	 */
27
+	public function run(TestResult $result = null);
28 28
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/AssertionFailedError.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@
 block discarded – undo
15 15
  */
16 16
 class AssertionFailedError extends Exception implements SelfDescribing
17 17
 {
18
-    /**
19
-     * Wrapper for getMessage() which is declared as final.
20
-     *
21
-     * @return string
22
-     */
23
-    public function toString()
24
-    {
25
-        return $this->getMessage();
26
-    }
18
+	/**
19
+	 * Wrapper for getMessage() which is declared as final.
20
+	 *
21
+	 * @return string
22
+	 */
23
+	public function toString()
24
+	{
25
+		return $this->getMessage();
26
+	}
27 27
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/TestCase.php 1 patch
Indentation   +2416 added lines, -2416 removed lines patch added patch discarded remove patch
@@ -100,2420 +100,2420 @@
 block discarded – undo
100 100
  */
101 101
 abstract class TestCase extends Assert implements Test, SelfDescribing
102 102
 {
103
-    /**
104
-     * Enable or disable the backup and restoration of the $GLOBALS array.
105
-     * Overwrite this attribute in a child class of TestCase.
106
-     * Setting this attribute in setUp() has no effect!
107
-     *
108
-     * @var bool
109
-     */
110
-    protected $backupGlobals;
111
-
112
-    /**
113
-     * @var array
114
-     */
115
-    protected $backupGlobalsBlacklist = [];
116
-
117
-    /**
118
-     * Enable or disable the backup and restoration of static attributes.
119
-     * Overwrite this attribute in a child class of TestCase.
120
-     * Setting this attribute in setUp() has no effect!
121
-     *
122
-     * @var bool
123
-     */
124
-    protected $backupStaticAttributes;
125
-
126
-    /**
127
-     * @var array
128
-     */
129
-    protected $backupStaticAttributesBlacklist = [];
130
-
131
-    /**
132
-     * Whether or not this test is to be run in a separate PHP process.
133
-     *
134
-     * @var bool
135
-     */
136
-    protected $runTestInSeparateProcess;
137
-
138
-    /**
139
-     * Whether or not this class is to be run in a separate PHP process.
140
-     *
141
-     * @var bool
142
-     */
143
-    private $runClassInSeparateProcess;
144
-
145
-    /**
146
-     * Whether or not this test should preserve the global state when
147
-     * running in a separate PHP process.
148
-     *
149
-     * @var bool
150
-     */
151
-    protected $preserveGlobalState = true;
152
-
153
-    /**
154
-     * Whether or not this test is running in a separate PHP process.
155
-     *
156
-     * @var bool
157
-     */
158
-    private $inIsolation = false;
159
-
160
-    /**
161
-     * @var array
162
-     */
163
-    private $data;
164
-
165
-    /**
166
-     * @var string
167
-     */
168
-    private $dataName;
169
-
170
-    /**
171
-     * @var bool
172
-     */
173
-    private $useErrorHandler;
174
-
175
-    /**
176
-     * The name of the expected Exception.
177
-     *
178
-     * @var null|string
179
-     */
180
-    private $expectedException;
181
-
182
-    /**
183
-     * The message of the expected Exception.
184
-     *
185
-     * @var string
186
-     */
187
-    private $expectedExceptionMessage;
188
-
189
-    /**
190
-     * The regex pattern to validate the expected Exception message.
191
-     *
192
-     * @var string
193
-     */
194
-    private $expectedExceptionMessageRegExp;
195
-
196
-    /**
197
-     * The code of the expected Exception.
198
-     *
199
-     * @var null|int|string
200
-     */
201
-    private $expectedExceptionCode;
202
-
203
-    /**
204
-     * The name of the test case.
205
-     *
206
-     * @var string
207
-     */
208
-    private $name;
209
-
210
-    /**
211
-     * @var string[]
212
-     */
213
-    private $dependencies = [];
214
-
215
-    /**
216
-     * @var array
217
-     */
218
-    private $dependencyInput = [];
219
-
220
-    /**
221
-     * @var array
222
-     */
223
-    private $iniSettings = [];
224
-
225
-    /**
226
-     * @var array
227
-     */
228
-    private $locale = [];
229
-
230
-    /**
231
-     * @var array
232
-     */
233
-    private $mockObjects = [];
234
-
235
-    /**
236
-     * @var array
237
-     */
238
-    private $mockObjectGenerator;
239
-
240
-    /**
241
-     * @var int
242
-     */
243
-    private $status;
244
-
245
-    /**
246
-     * @var string
247
-     */
248
-    private $statusMessage = '';
249
-
250
-    /**
251
-     * @var int
252
-     */
253
-    private $numAssertions = 0;
254
-
255
-    /**
256
-     * @var TestResult
257
-     */
258
-    private $result;
259
-
260
-    /**
261
-     * @var mixed
262
-     */
263
-    private $testResult;
264
-
265
-    /**
266
-     * @var string
267
-     */
268
-    private $output = '';
269
-
270
-    /**
271
-     * @var string
272
-     */
273
-    private $outputExpectedRegex;
274
-
275
-    /**
276
-     * @var string
277
-     */
278
-    private $outputExpectedString;
279
-
280
-    /**
281
-     * @var mixed
282
-     */
283
-    private $outputCallback = false;
284
-
285
-    /**
286
-     * @var bool
287
-     */
288
-    private $outputBufferingActive = false;
289
-
290
-    /**
291
-     * @var int
292
-     */
293
-    private $outputBufferingLevel;
294
-
295
-    /**
296
-     * @var SebastianBergmann\GlobalState\Snapshot
297
-     */
298
-    private $snapshot;
299
-
300
-    /**
301
-     * @var Prophecy\Prophet
302
-     */
303
-    private $prophet;
304
-
305
-    /**
306
-     * @var bool
307
-     */
308
-    private $beStrictAboutChangesToGlobalState = false;
309
-
310
-    /**
311
-     * @var bool
312
-     */
313
-    private $registerMockObjectsFromTestArgumentsRecursively = false;
314
-
315
-    /**
316
-     * @var string[]
317
-     */
318
-    private $warnings = [];
319
-
320
-    /**
321
-     * @var array
322
-     */
323
-    private $groups = [];
324
-
325
-    /**
326
-     * @var bool
327
-     */
328
-    private $doesNotPerformAssertions = false;
329
-
330
-    /**
331
-     * @var Comparator[]
332
-     */
333
-    private $customComparators = [];
334
-
335
-    /**
336
-     * Constructs a test case with the given name.
337
-     *
338
-     * @param string $name
339
-     * @param array  $data
340
-     * @param string $dataName
341
-     */
342
-    public function __construct($name = null, array $data = [], $dataName = '')
343
-    {
344
-        if ($name !== null) {
345
-            $this->setName($name);
346
-        }
347
-
348
-        $this->data     = $data;
349
-        $this->dataName = $dataName;
350
-    }
351
-
352
-    /**
353
-     * Returns a string representation of the test case.
354
-     *
355
-     * @return string
356
-     */
357
-    public function toString()
358
-    {
359
-        $class = new ReflectionClass($this);
360
-
361
-        $buffer = \sprintf(
362
-            '%s::%s',
363
-            $class->name,
364
-            $this->getName(false)
365
-        );
366
-
367
-        return $buffer . $this->getDataSetAsString();
368
-    }
369
-
370
-    /**
371
-     * Counts the number of test cases executed by run(TestResult result).
372
-     *
373
-     * @return int
374
-     */
375
-    public function count()
376
-    {
377
-        return 1;
378
-    }
379
-
380
-    public function getGroups()
381
-    {
382
-        return $this->groups;
383
-    }
384
-
385
-    /**
386
-     * @param array $groups
387
-     */
388
-    public function setGroups(array $groups)
389
-    {
390
-        $this->groups = $groups;
391
-    }
392
-
393
-    /**
394
-     * Returns the annotations for this test.
395
-     *
396
-     * @return array
397
-     */
398
-    public function getAnnotations()
399
-    {
400
-        return \PHPUnit\Util\Test::parseTestMethodAnnotations(
401
-            \get_class($this),
402
-            $this->name
403
-        );
404
-    }
405
-
406
-    /**
407
-     * Gets the name of a TestCase.
408
-     *
409
-     * @param bool $withDataSet
410
-     *
411
-     * @return string
412
-     */
413
-    public function getName($withDataSet = true)
414
-    {
415
-        if ($withDataSet) {
416
-            return $this->name . $this->getDataSetAsString(false);
417
-        }
418
-
419
-        return $this->name;
420
-    }
421
-
422
-    /**
423
-     * Returns the size of the test.
424
-     *
425
-     * @return int
426
-     */
427
-    public function getSize()
428
-    {
429
-        return \PHPUnit\Util\Test::getSize(
430
-            \get_class($this),
431
-            $this->getName(false)
432
-        );
433
-    }
434
-
435
-    /**
436
-     * @return bool
437
-     */
438
-    public function hasSize()
439
-    {
440
-        return $this->getSize() !== \PHPUnit\Util\Test::UNKNOWN;
441
-    }
442
-
443
-    /**
444
-     * @return bool
445
-     */
446
-    public function isSmall()
447
-    {
448
-        return $this->getSize() === \PHPUnit\Util\Test::SMALL;
449
-    }
450
-
451
-    /**
452
-     * @return bool
453
-     */
454
-    public function isMedium()
455
-    {
456
-        return $this->getSize() === \PHPUnit\Util\Test::MEDIUM;
457
-    }
458
-
459
-    /**
460
-     * @return bool
461
-     */
462
-    public function isLarge()
463
-    {
464
-        return $this->getSize() === \PHPUnit\Util\Test::LARGE;
465
-    }
466
-
467
-    /**
468
-     * @return string
469
-     */
470
-    public function getActualOutput()
471
-    {
472
-        if (!$this->outputBufferingActive) {
473
-            return $this->output;
474
-        }
475
-
476
-        return \ob_get_contents();
477
-    }
478
-
479
-    /**
480
-     * @return bool
481
-     */
482
-    public function hasOutput()
483
-    {
484
-        if (\strlen($this->output) === 0) {
485
-            return false;
486
-        }
487
-
488
-        if ($this->hasExpectationOnOutput()) {
489
-            return false;
490
-        }
491
-
492
-        return true;
493
-    }
494
-
495
-    /**
496
-     * @return bool
497
-     */
498
-    public function doesNotPerformAssertions()
499
-    {
500
-        return $this->doesNotPerformAssertions;
501
-    }
502
-
503
-    /**
504
-     * @param string $expectedRegex
505
-     *
506
-     * @throws Exception
507
-     */
508
-    public function expectOutputRegex($expectedRegex)
509
-    {
510
-        if ($this->outputExpectedString !== null) {
511
-            throw new Exception;
512
-        }
513
-
514
-        if (\is_string($expectedRegex) || null === $expectedRegex) {
515
-            $this->outputExpectedRegex = $expectedRegex;
516
-        }
517
-    }
518
-
519
-    /**
520
-     * @param string $expectedString
521
-     */
522
-    public function expectOutputString($expectedString)
523
-    {
524
-        if ($this->outputExpectedRegex !== null) {
525
-            throw new Exception;
526
-        }
527
-
528
-        if (\is_string($expectedString) || null === $expectedString) {
529
-            $this->outputExpectedString = $expectedString;
530
-        }
531
-    }
532
-
533
-    /**
534
-     * @return bool
535
-     */
536
-    public function hasExpectationOnOutput()
537
-    {
538
-        return \is_string($this->outputExpectedString) || \is_string($this->outputExpectedRegex);
539
-    }
540
-
541
-    /**
542
-     * @return null|string
543
-     */
544
-    public function getExpectedException()
545
-    {
546
-        return $this->expectedException;
547
-    }
548
-
549
-    /**
550
-     * @return null|int|string
551
-     */
552
-    public function getExpectedExceptionCode()
553
-    {
554
-        return $this->expectedExceptionCode;
555
-    }
556
-
557
-    /**
558
-     * @return string
559
-     */
560
-    public function getExpectedExceptionMessage()
561
-    {
562
-        return $this->expectedExceptionMessage;
563
-    }
564
-
565
-    /**
566
-     * @return string
567
-     */
568
-    public function getExpectedExceptionMessageRegExp()
569
-    {
570
-        return $this->expectedExceptionMessageRegExp;
571
-    }
572
-
573
-    /**
574
-     * @param string $exception
575
-     */
576
-    public function expectException($exception)
577
-    {
578
-        if (!\is_string($exception)) {
579
-            throw InvalidArgumentHelper::factory(1, 'string');
580
-        }
581
-
582
-        $this->expectedException = $exception;
583
-    }
584
-
585
-    /**
586
-     * @param int|string $code
587
-     *
588
-     * @throws Exception
589
-     */
590
-    public function expectExceptionCode($code)
591
-    {
592
-        if (!\is_int($code) && !\is_string($code)) {
593
-            throw InvalidArgumentHelper::factory(1, 'integer or string');
594
-        }
595
-
596
-        $this->expectedExceptionCode = $code;
597
-    }
598
-
599
-    /**
600
-     * @param string $message
601
-     *
602
-     * @throws Exception
603
-     */
604
-    public function expectExceptionMessage($message)
605
-    {
606
-        if (!\is_string($message)) {
607
-            throw InvalidArgumentHelper::factory(1, 'string');
608
-        }
609
-
610
-        $this->expectedExceptionMessage = $message;
611
-    }
612
-
613
-    /**
614
-     * @param string $messageRegExp
615
-     *
616
-     * @throws Exception
617
-     */
618
-    public function expectExceptionMessageRegExp($messageRegExp)
619
-    {
620
-        if (!\is_string($messageRegExp)) {
621
-            throw InvalidArgumentHelper::factory(1, 'string');
622
-        }
623
-
624
-        $this->expectedExceptionMessageRegExp = $messageRegExp;
625
-    }
626
-
627
-    /**
628
-     * Sets up an expectation for an exception to be raised by the code under test.
629
-     * Information for expected exception class, expected exception message, and
630
-     * expected exception code are retrieved from a given Exception object.
631
-     */
632
-    public function expectExceptionObject(\Exception $exception)
633
-    {
634
-        $this->expectException(\get_class($exception));
635
-        $this->expectExceptionMessage($exception->getMessage());
636
-        $this->expectExceptionCode($exception->getCode());
637
-    }
638
-
639
-    /**
640
-     * @param bool $flag
641
-     */
642
-    public function setRegisterMockObjectsFromTestArgumentsRecursively($flag)
643
-    {
644
-        if (!\is_bool($flag)) {
645
-            throw InvalidArgumentHelper::factory(1, 'boolean');
646
-        }
647
-
648
-        $this->registerMockObjectsFromTestArgumentsRecursively = $flag;
649
-    }
650
-
651
-    protected function setExpectedExceptionFromAnnotation()
652
-    {
653
-        try {
654
-            $expectedException = \PHPUnit\Util\Test::getExpectedException(
655
-                \get_class($this),
656
-                $this->name
657
-            );
658
-
659
-            if ($expectedException !== false) {
660
-                $this->expectException($expectedException['class']);
661
-
662
-                if ($expectedException['code'] !== null) {
663
-                    $this->expectExceptionCode($expectedException['code']);
664
-                }
665
-
666
-                if ($expectedException['message'] !== '') {
667
-                    $this->expectExceptionMessage($expectedException['message']);
668
-                } elseif ($expectedException['message_regex'] !== '') {
669
-                    $this->expectExceptionMessageRegExp($expectedException['message_regex']);
670
-                }
671
-            }
672
-        } catch (ReflectionException $e) {
673
-        }
674
-    }
675
-
676
-    /**
677
-     * @param bool $useErrorHandler
678
-     */
679
-    public function setUseErrorHandler($useErrorHandler)
680
-    {
681
-        $this->useErrorHandler = $useErrorHandler;
682
-    }
683
-
684
-    protected function setUseErrorHandlerFromAnnotation()
685
-    {
686
-        try {
687
-            $useErrorHandler = \PHPUnit\Util\Test::getErrorHandlerSettings(
688
-                \get_class($this),
689
-                $this->name
690
-            );
691
-
692
-            if ($useErrorHandler !== null) {
693
-                $this->setUseErrorHandler($useErrorHandler);
694
-            }
695
-        } catch (ReflectionException $e) {
696
-        }
697
-    }
698
-
699
-    protected function checkRequirements()
700
-    {
701
-        if (!$this->name || !\method_exists($this, $this->name)) {
702
-            return;
703
-        }
704
-
705
-        $missingRequirements = \PHPUnit\Util\Test::getMissingRequirements(
706
-            \get_class($this),
707
-            $this->name
708
-        );
709
-
710
-        if (!empty($missingRequirements)) {
711
-            $this->markTestSkipped(\implode(PHP_EOL, $missingRequirements));
712
-        }
713
-    }
714
-
715
-    /**
716
-     * Returns the status of this test.
717
-     *
718
-     * @return int
719
-     */
720
-    public function getStatus()
721
-    {
722
-        return $this->status;
723
-    }
724
-
725
-    public function markAsRisky()
726
-    {
727
-        $this->status = BaseTestRunner::STATUS_RISKY;
728
-    }
729
-
730
-    /**
731
-     * Returns the status message of this test.
732
-     *
733
-     * @return string
734
-     */
735
-    public function getStatusMessage()
736
-    {
737
-        return $this->statusMessage;
738
-    }
739
-
740
-    /**
741
-     * Returns whether or not this test has failed.
742
-     *
743
-     * @return bool
744
-     */
745
-    public function hasFailed()
746
-    {
747
-        $status = $this->getStatus();
748
-
749
-        return $status == BaseTestRunner::STATUS_FAILURE ||
750
-            $status == BaseTestRunner::STATUS_ERROR;
751
-    }
752
-
753
-    /**
754
-     * Runs the test case and collects the results in a TestResult object.
755
-     * If no TestResult object is passed a new one will be created.
756
-     *
757
-     * @param TestResult $result
758
-     *
759
-     * @return TestResult|null
760
-     *
761
-     * @throws Exception
762
-     */
763
-    public function run(TestResult $result = null)
764
-    {
765
-        if ($result === null) {
766
-            $result = $this->createResult();
767
-        }
768
-
769
-        if (!$this instanceof WarningTestCase) {
770
-            $this->setTestResultObject($result);
771
-            $this->setUseErrorHandlerFromAnnotation();
772
-        }
773
-
774
-        if ($this->useErrorHandler !== null) {
775
-            $oldErrorHandlerSetting = $result->getConvertErrorsToExceptions();
776
-            $result->convertErrorsToExceptions($this->useErrorHandler);
777
-        }
778
-
779
-        if (!$this instanceof WarningTestCase &&
780
-            !$this instanceof SkippedTestCase &&
781
-            !$this->handleDependencies()) {
782
-            return;
783
-        }
784
-
785
-        $runEntireClass =  $this->runClassInSeparateProcess && !$this->runTestInSeparateProcess;
786
-
787
-        if (($this->runTestInSeparateProcess === true || $this->runClassInSeparateProcess === true) &&
788
-            $this->inIsolation !== true &&
789
-            !$this instanceof PhptTestCase) {
790
-            $class = new ReflectionClass($this);
791
-
792
-            if ($runEntireClass) {
793
-                $template = new Text_Template(
794
-                    __DIR__ . '/../Util/PHP/Template/TestCaseClass.tpl'
795
-                );
796
-            } else {
797
-                $template = new Text_Template(
798
-                    __DIR__ . '/../Util/PHP/Template/TestCaseMethod.tpl'
799
-                );
800
-            }
801
-
802
-            if ($this->preserveGlobalState) {
803
-                $constants     = GlobalState::getConstantsAsString();
804
-                $globals       = GlobalState::getGlobalsAsString();
805
-                $includedFiles = GlobalState::getIncludedFilesAsString();
806
-                $iniSettings   = GlobalState::getIniSettingsAsString();
807
-            } else {
808
-                $constants = '';
809
-                if (!empty($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
810
-                    $globals = '$GLOBALS[\'__PHPUNIT_BOOTSTRAP\'] = ' . \var_export($GLOBALS['__PHPUNIT_BOOTSTRAP'], true) . ";\n";
811
-                } else {
812
-                    $globals = '';
813
-                }
814
-                $includedFiles = '';
815
-                $iniSettings   = '';
816
-            }
817
-
818
-            $coverage                                   = $result->getCollectCodeCoverageInformation() ? 'true' : 'false';
819
-            $isStrictAboutTestsThatDoNotTestAnything    = $result->isStrictAboutTestsThatDoNotTestAnything() ? 'true' : 'false';
820
-            $isStrictAboutOutputDuringTests             = $result->isStrictAboutOutputDuringTests() ? 'true' : 'false';
821
-            $enforcesTimeLimit                          = $result->enforcesTimeLimit() ? 'true' : 'false';
822
-            $isStrictAboutTodoAnnotatedTests            = $result->isStrictAboutTodoAnnotatedTests() ? 'true' : 'false';
823
-            $isStrictAboutResourceUsageDuringSmallTests = $result->isStrictAboutResourceUsageDuringSmallTests() ? 'true' : 'false';
824
-
825
-            if (\defined('PHPUNIT_COMPOSER_INSTALL')) {
826
-                $composerAutoload = \var_export(PHPUNIT_COMPOSER_INSTALL, true);
827
-            } else {
828
-                $composerAutoload = '\'\'';
829
-            }
830
-
831
-            if (\defined('__PHPUNIT_PHAR__')) {
832
-                $phar = \var_export(__PHPUNIT_PHAR__, true);
833
-            } else {
834
-                $phar = '\'\'';
835
-            }
836
-
837
-            if ($result->getCodeCoverage()) {
838
-                $codeCoverageFilter = $result->getCodeCoverage()->filter();
839
-            } else {
840
-                $codeCoverageFilter = null;
841
-            }
842
-
843
-            $data               = \var_export(\serialize($this->data), true);
844
-            $dataName           = \var_export($this->dataName, true);
845
-            $dependencyInput    = \var_export(\serialize($this->dependencyInput), true);
846
-            $includePath        = \var_export(\get_include_path(), true);
847
-            $codeCoverageFilter = \var_export(\serialize($codeCoverageFilter), true);
848
-            // must do these fixes because TestCaseMethod.tpl has unserialize('{data}') in it, and we can't break BC
849
-            // the lines above used to use addcslashes() rather than var_export(), which breaks null byte escape sequences
850
-            $data               = "'." . $data . ".'";
851
-            $dataName           = "'.(" . $dataName . ").'";
852
-            $dependencyInput    = "'." . $dependencyInput . ".'";
853
-            $includePath        = "'." . $includePath . ".'";
854
-            $codeCoverageFilter = "'." . $codeCoverageFilter . ".'";
855
-
856
-            $configurationFilePath = $GLOBALS['__PHPUNIT_CONFIGURATION_FILE'] ?? '';
857
-
858
-            $var = [
859
-                'composerAutoload'                           => $composerAutoload,
860
-                'phar'                                       => $phar,
861
-                'filename'                                   => $class->getFileName(),
862
-                'className'                                  => $class->getName(),
863
-                'collectCodeCoverageInformation'             => $coverage,
864
-                'data'                                       => $data,
865
-                'dataName'                                   => $dataName,
866
-                'dependencyInput'                            => $dependencyInput,
867
-                'constants'                                  => $constants,
868
-                'globals'                                    => $globals,
869
-                'include_path'                               => $includePath,
870
-                'included_files'                             => $includedFiles,
871
-                'iniSettings'                                => $iniSettings,
872
-                'isStrictAboutTestsThatDoNotTestAnything'    => $isStrictAboutTestsThatDoNotTestAnything,
873
-                'isStrictAboutOutputDuringTests'             => $isStrictAboutOutputDuringTests,
874
-                'enforcesTimeLimit'                          => $enforcesTimeLimit,
875
-                'isStrictAboutTodoAnnotatedTests'            => $isStrictAboutTodoAnnotatedTests,
876
-                'isStrictAboutResourceUsageDuringSmallTests' => $isStrictAboutResourceUsageDuringSmallTests,
877
-                'codeCoverageFilter'                         => $codeCoverageFilter,
878
-                'configurationFilePath'                      => $configurationFilePath
879
-            ];
880
-
881
-            if (!$runEntireClass) {
882
-                $var['methodName'] = $this->name;
883
-            }
884
-
885
-            $template->setVar(
886
-                $var
887
-            );
888
-
889
-            $this->prepareTemplate($template);
890
-
891
-            $php = AbstractPhpProcess::factory();
892
-            $php->runTestJob($template->render(), $this, $result);
893
-        } else {
894
-            $result->run($this);
895
-        }
896
-
897
-        if (isset($oldErrorHandlerSetting)) {
898
-            $result->convertErrorsToExceptions($oldErrorHandlerSetting);
899
-        }
900
-
901
-        $this->result = null;
902
-
903
-        return $result;
904
-    }
905
-
906
-    /**
907
-     * Runs the bare test sequence.
908
-     */
909
-    public function runBare()
910
-    {
911
-        $this->numAssertions = 0;
912
-
913
-        $this->snapshotGlobalState();
914
-        $this->startOutputBuffering();
915
-        \clearstatcache();
916
-        $currentWorkingDirectory = \getcwd();
917
-
918
-        $hookMethods = \PHPUnit\Util\Test::getHookMethods(\get_class($this));
919
-
920
-        try {
921
-            $hasMetRequirements = false;
922
-            $this->checkRequirements();
923
-            $hasMetRequirements = true;
924
-
925
-            if ($this->inIsolation) {
926
-                foreach ($hookMethods['beforeClass'] as $method) {
927
-                    $this->$method();
928
-                }
929
-            }
930
-
931
-            $this->setExpectedExceptionFromAnnotation();
932
-            $this->setDoesNotPerformAssertionsFromAnnotation();
933
-
934
-            foreach ($hookMethods['before'] as $method) {
935
-                $this->$method();
936
-            }
937
-
938
-            $this->assertPreConditions();
939
-            $this->testResult = $this->runTest();
940
-            $this->verifyMockObjects();
941
-            $this->assertPostConditions();
942
-
943
-            if (!empty($this->warnings)) {
944
-                throw new Warning(
945
-                    \implode(
946
-                        "\n",
947
-                        \array_unique($this->warnings)
948
-                    )
949
-                );
950
-            }
951
-
952
-            $this->status = BaseTestRunner::STATUS_PASSED;
953
-        } catch (IncompleteTest $e) {
954
-            $this->status        = BaseTestRunner::STATUS_INCOMPLETE;
955
-            $this->statusMessage = $e->getMessage();
956
-        } catch (SkippedTest $e) {
957
-            $this->status        = BaseTestRunner::STATUS_SKIPPED;
958
-            $this->statusMessage = $e->getMessage();
959
-        } catch (Warning $e) {
960
-            $this->status        = BaseTestRunner::STATUS_WARNING;
961
-            $this->statusMessage = $e->getMessage();
962
-        } catch (AssertionFailedError $e) {
963
-            $this->status        = BaseTestRunner::STATUS_FAILURE;
964
-            $this->statusMessage = $e->getMessage();
965
-        } catch (PredictionException $e) {
966
-            $this->status        = BaseTestRunner::STATUS_FAILURE;
967
-            $this->statusMessage = $e->getMessage();
968
-        } catch (Throwable $_e) {
969
-            $e = $_e;
970
-        }
971
-
972
-        if (isset($_e)) {
973
-            $this->status        = BaseTestRunner::STATUS_ERROR;
974
-            $this->statusMessage = $_e->getMessage();
975
-        }
976
-
977
-        // Clean up the mock objects.
978
-        $this->mockObjects = [];
979
-        $this->prophet     = null;
980
-
981
-        // Tear down the fixture. An exception raised in tearDown() will be
982
-        // caught and passed on when no exception was raised before.
983
-        try {
984
-            if ($hasMetRequirements) {
985
-                foreach ($hookMethods['after'] as $method) {
986
-                    $this->$method();
987
-                }
988
-
989
-                if ($this->inIsolation) {
990
-                    foreach ($hookMethods['afterClass'] as $method) {
991
-                        $this->$method();
992
-                    }
993
-                }
994
-            }
995
-        } catch (Throwable $_e) {
996
-            if (!isset($e)) {
997
-                $e = $_e;
998
-            }
999
-        }
1000
-
1001
-        try {
1002
-            $this->stopOutputBuffering();
1003
-        } catch (RiskyTestError $_e) {
1004
-            if (!isset($e)) {
1005
-                $e = $_e;
1006
-            }
1007
-        }
1008
-
1009
-        \clearstatcache();
1010
-
1011
-        if ($currentWorkingDirectory != \getcwd()) {
1012
-            \chdir($currentWorkingDirectory);
1013
-        }
1014
-
1015
-        $this->restoreGlobalState();
1016
-        $this->unregisterCustomComparators();
1017
-        $this->cleanupIniSettings();
1018
-        $this->cleanupLocaleSettings();
1019
-
1020
-        // Perform assertion on output.
1021
-        if (!isset($e)) {
1022
-            try {
1023
-                if ($this->outputExpectedRegex !== null) {
1024
-                    $this->assertRegExp($this->outputExpectedRegex, $this->output);
1025
-                } elseif ($this->outputExpectedString !== null) {
1026
-                    $this->assertEquals($this->outputExpectedString, $this->output);
1027
-                }
1028
-            } catch (Throwable $_e) {
1029
-                $e = $_e;
1030
-            }
1031
-        }
1032
-
1033
-        // Workaround for missing "finally".
1034
-        if (isset($e)) {
1035
-            if ($e instanceof PredictionException) {
1036
-                $e = new AssertionFailedError($e->getMessage());
1037
-            }
1038
-
1039
-            $this->onNotSuccessfulTest($e);
1040
-        }
1041
-    }
1042
-
1043
-    /**
1044
-     * Override to run the test and assert its state.
1045
-     *
1046
-     * @return mixed
1047
-     *
1048
-     * @throws Exception|Exception
1049
-     * @throws Exception
1050
-     */
1051
-    protected function runTest()
1052
-    {
1053
-        if ($this->name === null) {
1054
-            throw new Exception(
1055
-                'PHPUnit\Framework\TestCase::$name must not be null.'
1056
-            );
1057
-        }
1058
-
1059
-        try {
1060
-            $class  = new ReflectionClass($this);
1061
-            $method = $class->getMethod($this->name);
1062
-        } catch (ReflectionException $e) {
1063
-            $this->fail($e->getMessage());
1064
-        }
1065
-
1066
-        $testArguments = \array_merge($this->data, $this->dependencyInput);
1067
-
1068
-        $this->registerMockObjectsFromTestArguments($testArguments);
1069
-
1070
-        try {
1071
-            $testResult = $method->invokeArgs($this, $testArguments);
1072
-        } catch (Throwable $t) {
1073
-            $exception = $t;
1074
-        }
1075
-
1076
-        if (isset($exception)) {
1077
-            if ($this->checkExceptionExpectations($exception)) {
1078
-                if ($this->expectedException !== null) {
1079
-                    $this->assertThat(
1080
-                        $exception,
1081
-                        new ExceptionConstraint(
1082
-                            $this->expectedException
1083
-                        )
1084
-                    );
1085
-                }
1086
-
1087
-                if ($this->expectedExceptionMessage !== null) {
1088
-                    $this->assertThat(
1089
-                        $exception,
1090
-                        new ExceptionMessage(
1091
-                            $this->expectedExceptionMessage
1092
-                        )
1093
-                    );
1094
-                }
1095
-
1096
-                if ($this->expectedExceptionMessageRegExp !== null) {
1097
-                    $this->assertThat(
1098
-                        $exception,
1099
-                        new ExceptionMessageRegularExpression(
1100
-                            $this->expectedExceptionMessageRegExp
1101
-                        )
1102
-                    );
1103
-                }
1104
-
1105
-                if ($this->expectedExceptionCode !== null) {
1106
-                    $this->assertThat(
1107
-                        $exception,
1108
-                        new ExceptionCode(
1109
-                            $this->expectedExceptionCode
1110
-                        )
1111
-                    );
1112
-                }
1113
-
1114
-                return;
1115
-            }
1116
-
1117
-            throw $exception;
1118
-        }
1119
-
1120
-        if ($this->expectedException !== null) {
1121
-            $this->assertThat(
1122
-                null,
1123
-                new ExceptionConstraint(
1124
-                    $this->expectedException
1125
-                )
1126
-            );
1127
-        } elseif ($this->expectedExceptionMessage !== null) {
1128
-            $this->numAssertions++;
1129
-
1130
-            throw new AssertionFailedError(
1131
-                \sprintf(
1132
-                    'Failed asserting that exception with message "%s" is thrown',
1133
-                    $this->expectedExceptionMessage
1134
-                )
1135
-            );
1136
-        } elseif ($this->expectedExceptionMessageRegExp !== null) {
1137
-            $this->numAssertions++;
1138
-
1139
-            throw new AssertionFailedError(
1140
-                \sprintf(
1141
-                    'Failed asserting that exception with message matching "%s" is thrown',
1142
-                    $this->expectedExceptionMessageRegExp
1143
-                )
1144
-            );
1145
-        } elseif ($this->expectedExceptionCode !== null) {
1146
-            $this->numAssertions++;
1147
-
1148
-            throw new AssertionFailedError(
1149
-                \sprintf(
1150
-                    'Failed asserting that exception with code "%s" is thrown',
1151
-                    $this->expectedExceptionCode
1152
-                )
1153
-            );
1154
-        }
1155
-
1156
-        return $testResult;
1157
-    }
1158
-
1159
-    /**
1160
-     * Verifies the mock object expectations.
1161
-     */
1162
-    protected function verifyMockObjects()
1163
-    {
1164
-        foreach ($this->mockObjects as $mockObject) {
1165
-            if ($mockObject->__phpunit_hasMatchers()) {
1166
-                $this->numAssertions++;
1167
-            }
1168
-
1169
-            $mockObject->__phpunit_verify(
1170
-                $this->shouldInvocationMockerBeReset($mockObject)
1171
-            );
1172
-        }
1173
-
1174
-        if ($this->prophet !== null) {
1175
-            try {
1176
-                $this->prophet->checkPredictions();
1177
-            } catch (Throwable $t) {
1178
-                /* Intentionally left empty */
1179
-            }
1180
-
1181
-            foreach ($this->prophet->getProphecies() as $objectProphecy) {
1182
-                foreach ($objectProphecy->getMethodProphecies() as $methodProphecies) {
1183
-                    foreach ($methodProphecies as $methodProphecy) {
1184
-                        $this->numAssertions += \count($methodProphecy->getCheckedPredictions());
1185
-                    }
1186
-                }
1187
-            }
1188
-
1189
-            if (isset($t)) {
1190
-                throw $t;
1191
-            }
1192
-        }
1193
-    }
1194
-
1195
-    /**
1196
-     * Sets the name of a TestCase.
1197
-     *
1198
-     * @param  string
1199
-     */
1200
-    public function setName($name)
1201
-    {
1202
-        $this->name = $name;
1203
-    }
1204
-
1205
-    /**
1206
-     * Sets the dependencies of a TestCase.
1207
-     *
1208
-     * @param string[] $dependencies
1209
-     */
1210
-    public function setDependencies(array $dependencies)
1211
-    {
1212
-        $this->dependencies = $dependencies;
1213
-    }
1214
-
1215
-    /**
1216
-     * Returns true if the tests has dependencies
1217
-     *
1218
-     * @return bool
1219
-     */
1220
-    public function hasDependencies()
1221
-    {
1222
-        return \count($this->dependencies) > 0;
1223
-    }
1224
-
1225
-    /**
1226
-     * Sets
1227
-     *
1228
-     * @param array $dependencyInput
1229
-     */
1230
-    public function setDependencyInput(array $dependencyInput)
1231
-    {
1232
-        $this->dependencyInput = $dependencyInput;
1233
-    }
1234
-
1235
-    /**
1236
-     * @param bool $beStrictAboutChangesToGlobalState
1237
-     */
1238
-    public function setBeStrictAboutChangesToGlobalState($beStrictAboutChangesToGlobalState)
1239
-    {
1240
-        $this->beStrictAboutChangesToGlobalState = $beStrictAboutChangesToGlobalState;
1241
-    }
1242
-
1243
-    /**
1244
-     * Calling this method in setUp() has no effect!
1245
-     *
1246
-     * @param bool $backupGlobals
1247
-     */
1248
-    public function setBackupGlobals($backupGlobals)
1249
-    {
1250
-        if (null === $this->backupGlobals && \is_bool($backupGlobals)) {
1251
-            $this->backupGlobals = $backupGlobals;
1252
-        }
1253
-    }
1254
-
1255
-    /**
1256
-     * Calling this method in setUp() has no effect!
1257
-     *
1258
-     * @param bool $backupStaticAttributes
1259
-     */
1260
-    public function setBackupStaticAttributes($backupStaticAttributes)
1261
-    {
1262
-        if (null === $this->backupStaticAttributes &&
1263
-            \is_bool($backupStaticAttributes)) {
1264
-            $this->backupStaticAttributes = $backupStaticAttributes;
1265
-        }
1266
-    }
1267
-
1268
-    /**
1269
-     * @param bool $runTestInSeparateProcess
1270
-     *
1271
-     * @throws Exception
1272
-     */
1273
-    public function setRunTestInSeparateProcess($runTestInSeparateProcess)
1274
-    {
1275
-        if (\is_bool($runTestInSeparateProcess)) {
1276
-            if ($this->runTestInSeparateProcess === null) {
1277
-                $this->runTestInSeparateProcess = $runTestInSeparateProcess;
1278
-            }
1279
-        } else {
1280
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1281
-        }
1282
-    }
1283
-
1284
-    /**
1285
-     * @param bool $runClassInSeparateProcess
1286
-     *
1287
-     * @throws Exception
1288
-     */
1289
-    public function setRunClassInSeparateProcess($runClassInSeparateProcess)
1290
-    {
1291
-        if (\is_bool($runClassInSeparateProcess)) {
1292
-            if ($this->runClassInSeparateProcess === null) {
1293
-                $this->runClassInSeparateProcess = $runClassInSeparateProcess;
1294
-            }
1295
-        } else {
1296
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1297
-        }
1298
-    }
1299
-
1300
-    /**
1301
-     * @param bool $preserveGlobalState
1302
-     *
1303
-     * @throws Exception
1304
-     */
1305
-    public function setPreserveGlobalState($preserveGlobalState)
1306
-    {
1307
-        if (\is_bool($preserveGlobalState)) {
1308
-            $this->preserveGlobalState = $preserveGlobalState;
1309
-        } else {
1310
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1311
-        }
1312
-    }
1313
-
1314
-    /**
1315
-     * @param bool $inIsolation
1316
-     *
1317
-     * @throws Exception
1318
-     */
1319
-    public function setInIsolation($inIsolation)
1320
-    {
1321
-        if (\is_bool($inIsolation)) {
1322
-            $this->inIsolation = $inIsolation;
1323
-        } else {
1324
-            throw InvalidArgumentHelper::factory(1, 'boolean');
1325
-        }
1326
-    }
1327
-
1328
-    /**
1329
-     * @return bool
1330
-     */
1331
-    public function isInIsolation()
1332
-    {
1333
-        return $this->inIsolation;
1334
-    }
1335
-
1336
-    /**
1337
-     * @return mixed
1338
-     */
1339
-    public function getResult()
1340
-    {
1341
-        return $this->testResult;
1342
-    }
1343
-
1344
-    /**
1345
-     * @param mixed $result
1346
-     */
1347
-    public function setResult($result)
1348
-    {
1349
-        $this->testResult = $result;
1350
-    }
1351
-
1352
-    /**
1353
-     * @param callable $callback
1354
-     *
1355
-     * @throws Exception
1356
-     */
1357
-    public function setOutputCallback($callback)
1358
-    {
1359
-        if (!\is_callable($callback)) {
1360
-            throw InvalidArgumentHelper::factory(1, 'callback');
1361
-        }
1362
-
1363
-        $this->outputCallback = $callback;
1364
-    }
1365
-
1366
-    /**
1367
-     * @return TestResult
1368
-     */
1369
-    public function getTestResultObject()
1370
-    {
1371
-        return $this->result;
1372
-    }
1373
-
1374
-    /**
1375
-     * @param TestResult $result
1376
-     */
1377
-    public function setTestResultObject(TestResult $result)
1378
-    {
1379
-        $this->result = $result;
1380
-    }
1381
-
1382
-    /**
1383
-     * @param PHPUnit_Framework_MockObject_MockObject $mockObject
1384
-     */
1385
-    public function registerMockObject(PHPUnit_Framework_MockObject_MockObject $mockObject)
1386
-    {
1387
-        $this->mockObjects[] = $mockObject;
1388
-    }
1389
-
1390
-    /**
1391
-     * This method is a wrapper for the ini_set() function that automatically
1392
-     * resets the modified php.ini setting to its original value after the
1393
-     * test is run.
1394
-     *
1395
-     * @param string $varName
1396
-     * @param string $newValue
1397
-     *
1398
-     * @throws Exception
1399
-     */
1400
-    protected function iniSet($varName, $newValue)
1401
-    {
1402
-        if (!\is_string($varName)) {
1403
-            throw InvalidArgumentHelper::factory(1, 'string');
1404
-        }
1405
-
1406
-        $currentValue = \ini_set($varName, $newValue);
1407
-
1408
-        if ($currentValue !== false) {
1409
-            $this->iniSettings[$varName] = $currentValue;
1410
-        } else {
1411
-            throw new Exception(
1412
-                \sprintf(
1413
-                    'INI setting "%s" could not be set to "%s".',
1414
-                    $varName,
1415
-                    $newValue
1416
-                )
1417
-            );
1418
-        }
1419
-    }
1420
-
1421
-    /**
1422
-     * This method is a wrapper for the setlocale() function that automatically
1423
-     * resets the locale to its original value after the test is run.
1424
-     *
1425
-     * @param int    $category
1426
-     * @param string $locale
1427
-     *
1428
-     * @throws Exception
1429
-     */
1430
-    protected function setLocale()
1431
-    {
1432
-        $args = \func_get_args();
1433
-
1434
-        if (\count($args) < 2) {
1435
-            throw new Exception;
1436
-        }
1437
-
1438
-        list($category, $locale) = $args;
1439
-
1440
-        $categories = [
1441
-            LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME
1442
-        ];
1443
-
1444
-        if (\defined('LC_MESSAGES')) {
1445
-            $categories[] = LC_MESSAGES;
1446
-        }
1447
-
1448
-        if (!\in_array($category, $categories)) {
1449
-            throw new Exception;
1450
-        }
1451
-
1452
-        if (!\is_array($locale) && !\is_string($locale)) {
1453
-            throw new Exception;
1454
-        }
1455
-
1456
-        $this->locale[$category] = \setlocale($category, 0);
1457
-
1458
-        $result = \call_user_func_array('setlocale', $args);
1459
-
1460
-        if ($result === false) {
1461
-            throw new Exception(
1462
-                'The locale functionality is not implemented on your platform, ' .
1463
-                'the specified locale does not exist or the category name is ' .
1464
-                'invalid.'
1465
-            );
1466
-        }
1467
-    }
1468
-
1469
-    /**
1470
-     * Returns a builder object to create mock objects using a fluent interface.
1471
-     *
1472
-     * @param string|string[] $className
1473
-     *
1474
-     * @return PHPUnit_Framework_MockObject_MockBuilder
1475
-     */
1476
-    public function getMockBuilder($className)
1477
-    {
1478
-        return new PHPUnit_Framework_MockObject_MockBuilder($this, $className);
1479
-    }
1480
-
1481
-    /**
1482
-     * Returns a test double for the specified class.
1483
-     *
1484
-     * @param string $originalClassName
1485
-     *
1486
-     * @return PHPUnit_Framework_MockObject_MockObject
1487
-     *
1488
-     * @throws Exception
1489
-     */
1490
-    protected function createMock($originalClassName)
1491
-    {
1492
-        return $this->getMockBuilder($originalClassName)
1493
-            ->disableOriginalConstructor()
1494
-            ->disableOriginalClone()
1495
-            ->disableArgumentCloning()
1496
-            ->disallowMockingUnknownTypes()
1497
-            ->getMock();
1498
-    }
1499
-
1500
-    /**
1501
-     * Returns a configured test double for the specified class.
1502
-     *
1503
-     * @param string $originalClassName
1504
-     * @param array  $configuration
1505
-     *
1506
-     * @return PHPUnit_Framework_MockObject_MockObject
1507
-     *
1508
-     * @throws Exception
1509
-     */
1510
-    protected function createConfiguredMock($originalClassName, array $configuration)
1511
-    {
1512
-        $o = $this->createMock($originalClassName);
1513
-
1514
-        foreach ($configuration as $method => $return) {
1515
-            $o->method($method)->willReturn($return);
1516
-        }
1517
-
1518
-        return $o;
1519
-    }
1520
-
1521
-    /**
1522
-     * Returns a partial test double for the specified class.
1523
-     *
1524
-     * @param string   $originalClassName
1525
-     * @param string[] $methods
1526
-     *
1527
-     * @return PHPUnit_Framework_MockObject_MockObject
1528
-     *
1529
-     * @throws Exception
1530
-     */
1531
-    protected function createPartialMock($originalClassName, array $methods)
1532
-    {
1533
-        return $this->getMockBuilder($originalClassName)
1534
-            ->disableOriginalConstructor()
1535
-            ->disableOriginalClone()
1536
-            ->disableArgumentCloning()
1537
-            ->disallowMockingUnknownTypes()
1538
-            ->setMethods(empty($methods) ? null : $methods)
1539
-            ->getMock();
1540
-    }
1541
-
1542
-    /**
1543
-     * Returns a test proxy for the specified class.
1544
-     *
1545
-     * @param string $originalClassName
1546
-     * @param array  $constructorArguments
1547
-     *
1548
-     * @return PHPUnit_Framework_MockObject_MockObject
1549
-     *
1550
-     * @throws Exception
1551
-     */
1552
-    protected function createTestProxy($originalClassName, array $constructorArguments = [])
1553
-    {
1554
-        return $this->getMockBuilder($originalClassName)
1555
-            ->setConstructorArgs($constructorArguments)
1556
-            ->enableProxyingToOriginalMethods()
1557
-            ->getMock();
1558
-    }
1559
-
1560
-    /**
1561
-     * Mocks the specified class and returns the name of the mocked class.
1562
-     *
1563
-     * @param string $originalClassName
1564
-     * @param array  $methods
1565
-     * @param array  $arguments
1566
-     * @param string $mockClassName
1567
-     * @param bool   $callOriginalConstructor
1568
-     * @param bool   $callOriginalClone
1569
-     * @param bool   $callAutoload
1570
-     * @param bool   $cloneArguments
1571
-     *
1572
-     * @return string
1573
-     *
1574
-     * @throws Exception
1575
-     */
1576
-    protected function getMockClass($originalClassName, $methods = [], array $arguments = [], $mockClassName = '', $callOriginalConstructor = false, $callOriginalClone = true, $callAutoload = true, $cloneArguments = false)
1577
-    {
1578
-        $mock = $this->getMockObjectGenerator()->getMock(
1579
-            $originalClassName,
1580
-            $methods,
1581
-            $arguments,
1582
-            $mockClassName,
1583
-            $callOriginalConstructor,
1584
-            $callOriginalClone,
1585
-            $callAutoload,
1586
-            $cloneArguments
1587
-        );
1588
-
1589
-        return \get_class($mock);
1590
-    }
1591
-
1592
-    /**
1593
-     * Returns a mock object for the specified abstract class with all abstract
1594
-     * methods of the class mocked. Concrete methods are not mocked by default.
1595
-     * To mock concrete methods, use the 7th parameter ($mockedMethods).
1596
-     *
1597
-     * @param string $originalClassName
1598
-     * @param array  $arguments
1599
-     * @param string $mockClassName
1600
-     * @param bool   $callOriginalConstructor
1601
-     * @param bool   $callOriginalClone
1602
-     * @param bool   $callAutoload
1603
-     * @param array  $mockedMethods
1604
-     * @param bool   $cloneArguments
1605
-     *
1606
-     * @return PHPUnit_Framework_MockObject_MockObject
1607
-     *
1608
-     * @throws Exception
1609
-     */
1610
-    protected function getMockForAbstractClass($originalClassName, array $arguments = [], $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true, $mockedMethods = [], $cloneArguments = false)
1611
-    {
1612
-        $mockObject = $this->getMockObjectGenerator()->getMockForAbstractClass(
1613
-            $originalClassName,
1614
-            $arguments,
1615
-            $mockClassName,
1616
-            $callOriginalConstructor,
1617
-            $callOriginalClone,
1618
-            $callAutoload,
1619
-            $mockedMethods,
1620
-            $cloneArguments
1621
-        );
1622
-
1623
-        $this->registerMockObject($mockObject);
1624
-
1625
-        return $mockObject;
1626
-    }
1627
-
1628
-    /**
1629
-     * Returns a mock object based on the given WSDL file.
1630
-     *
1631
-     * @param string $wsdlFile
1632
-     * @param string $originalClassName
1633
-     * @param string $mockClassName
1634
-     * @param array  $methods
1635
-     * @param bool   $callOriginalConstructor
1636
-     * @param array  $options                 An array of options passed to SOAPClient::_construct
1637
-     *
1638
-     * @return PHPUnit_Framework_MockObject_MockObject
1639
-     */
1640
-    protected function getMockFromWsdl($wsdlFile, $originalClassName = '', $mockClassName = '', array $methods = [], $callOriginalConstructor = true, array $options = [])
1641
-    {
1642
-        if ($originalClassName === '') {
1643
-            $originalClassName = \pathinfo(\basename(\parse_url($wsdlFile)['path']), PATHINFO_FILENAME);
1644
-        }
1645
-
1646
-        if (!\class_exists($originalClassName)) {
1647
-            eval(
1648
-                $this->getMockObjectGenerator()->generateClassFromWsdl(
1649
-                    $wsdlFile,
1650
-                    $originalClassName,
1651
-                    $methods,
1652
-                    $options
1653
-                )
1654
-            );
1655
-        }
1656
-
1657
-        $mockObject = $this->getMockObjectGenerator()->getMock(
1658
-            $originalClassName,
1659
-            $methods,
1660
-            ['', $options],
1661
-            $mockClassName,
1662
-            $callOriginalConstructor,
1663
-            false,
1664
-            false
1665
-        );
1666
-
1667
-        $this->registerMockObject($mockObject);
1668
-
1669
-        return $mockObject;
1670
-    }
1671
-
1672
-    /**
1673
-     * Returns a mock object for the specified trait with all abstract methods
1674
-     * of the trait mocked. Concrete methods to mock can be specified with the
1675
-     * `$mockedMethods` parameter.
1676
-     *
1677
-     * @param string $traitName
1678
-     * @param array  $arguments
1679
-     * @param string $mockClassName
1680
-     * @param bool   $callOriginalConstructor
1681
-     * @param bool   $callOriginalClone
1682
-     * @param bool   $callAutoload
1683
-     * @param array  $mockedMethods
1684
-     * @param bool   $cloneArguments
1685
-     *
1686
-     * @return PHPUnit_Framework_MockObject_MockObject
1687
-     *
1688
-     * @throws Exception
1689
-     */
1690
-    protected function getMockForTrait($traitName, array $arguments = [], $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true, $mockedMethods = [], $cloneArguments = false)
1691
-    {
1692
-        $mockObject = $this->getMockObjectGenerator()->getMockForTrait(
1693
-            $traitName,
1694
-            $arguments,
1695
-            $mockClassName,
1696
-            $callOriginalConstructor,
1697
-            $callOriginalClone,
1698
-            $callAutoload,
1699
-            $mockedMethods,
1700
-            $cloneArguments
1701
-        );
1702
-
1703
-        $this->registerMockObject($mockObject);
1704
-
1705
-        return $mockObject;
1706
-    }
1707
-
1708
-    /**
1709
-     * Returns an object for the specified trait.
1710
-     *
1711
-     * @param string $traitName
1712
-     * @param array  $arguments
1713
-     * @param string $traitClassName
1714
-     * @param bool   $callOriginalConstructor
1715
-     * @param bool   $callOriginalClone
1716
-     * @param bool   $callAutoload
1717
-     *
1718
-     * @return object
1719
-     *
1720
-     * @throws Exception
1721
-     */
1722
-    protected function getObjectForTrait($traitName, array $arguments = [], $traitClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true)
1723
-    {
1724
-        return $this->getMockObjectGenerator()->getObjectForTrait(
1725
-            $traitName,
1726
-            $arguments,
1727
-            $traitClassName,
1728
-            $callOriginalConstructor,
1729
-            $callOriginalClone,
1730
-            $callAutoload
1731
-        );
1732
-    }
1733
-
1734
-    /**
1735
-     * @param string|null $classOrInterface
1736
-     *
1737
-     * @return \Prophecy\Prophecy\ObjectProphecy
1738
-     *
1739
-     * @throws \LogicException
1740
-     */
1741
-    protected function prophesize($classOrInterface = null)
1742
-    {
1743
-        return $this->getProphet()->prophesize($classOrInterface);
1744
-    }
1745
-
1746
-    /**
1747
-     * Adds a value to the assertion counter.
1748
-     *
1749
-     * @param int $count
1750
-     */
1751
-    public function addToAssertionCount($count)
1752
-    {
1753
-        $this->numAssertions += $count;
1754
-    }
1755
-
1756
-    /**
1757
-     * Returns the number of assertions performed by this test.
1758
-     *
1759
-     * @return int
1760
-     */
1761
-    public function getNumAssertions()
1762
-    {
1763
-        return $this->numAssertions;
1764
-    }
1765
-
1766
-    /**
1767
-     * Returns a matcher that matches when the method is executed
1768
-     * zero or more times.
1769
-     *
1770
-     * @return PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount
1771
-     */
1772
-    public static function any()
1773
-    {
1774
-        return new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
1775
-    }
1776
-
1777
-    /**
1778
-     * Returns a matcher that matches when the method is never executed.
1779
-     *
1780
-     * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
1781
-     */
1782
-    public static function never()
1783
-    {
1784
-        return new PHPUnit_Framework_MockObject_Matcher_InvokedCount(0);
1785
-    }
1786
-
1787
-    /**
1788
-     * Returns a matcher that matches when the method is executed
1789
-     * at least N times.
1790
-     *
1791
-     * @param int $requiredInvocations
1792
-     *
1793
-     * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastCount
1794
-     */
1795
-    public static function atLeast($requiredInvocations)
1796
-    {
1797
-        return new PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastCount(
1798
-            $requiredInvocations
1799
-        );
1800
-    }
1801
-
1802
-    /**
1803
-     * Returns a matcher that matches when the method is executed at least once.
1804
-     *
1805
-     * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce
1806
-     */
1807
-    public static function atLeastOnce()
1808
-    {
1809
-        return new PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce;
1810
-    }
1811
-
1812
-    /**
1813
-     * Returns a matcher that matches when the method is executed exactly once.
1814
-     *
1815
-     * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
1816
-     */
1817
-    public static function once()
1818
-    {
1819
-        return new PHPUnit_Framework_MockObject_Matcher_InvokedCount(1);
1820
-    }
1821
-
1822
-    /**
1823
-     * Returns a matcher that matches when the method is executed
1824
-     * exactly $count times.
1825
-     *
1826
-     * @param int $count
1827
-     *
1828
-     * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
1829
-     */
1830
-    public static function exactly($count)
1831
-    {
1832
-        return new PHPUnit_Framework_MockObject_Matcher_InvokedCount($count);
1833
-    }
1834
-
1835
-    /**
1836
-     * Returns a matcher that matches when the method is executed
1837
-     * at most N times.
1838
-     *
1839
-     * @param int $allowedInvocations
1840
-     *
1841
-     * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtMostCount
1842
-     */
1843
-    public static function atMost($allowedInvocations)
1844
-    {
1845
-        return new PHPUnit_Framework_MockObject_Matcher_InvokedAtMostCount(
1846
-            $allowedInvocations
1847
-        );
1848
-    }
1849
-
1850
-    /**
1851
-     * Returns a matcher that matches when the method is executed
1852
-     * at the given index.
1853
-     *
1854
-     * @param int $index
1855
-     *
1856
-     * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex
1857
-     */
1858
-    public static function at($index)
1859
-    {
1860
-        return new PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex($index);
1861
-    }
1862
-
1863
-    /**
1864
-     * @param mixed $value
1865
-     *
1866
-     * @return PHPUnit_Framework_MockObject_Stub_Return
1867
-     */
1868
-    public static function returnValue($value)
1869
-    {
1870
-        return new PHPUnit_Framework_MockObject_Stub_Return($value);
1871
-    }
1872
-
1873
-    /**
1874
-     * @param array $valueMap
1875
-     *
1876
-     * @return PHPUnit_Framework_MockObject_Stub_ReturnValueMap
1877
-     */
1878
-    public static function returnValueMap(array $valueMap)
1879
-    {
1880
-        return new PHPUnit_Framework_MockObject_Stub_ReturnValueMap($valueMap);
1881
-    }
1882
-
1883
-    /**
1884
-     * @param int $argumentIndex
1885
-     *
1886
-     * @return PHPUnit_Framework_MockObject_Stub_ReturnArgument
1887
-     */
1888
-    public static function returnArgument($argumentIndex)
1889
-    {
1890
-        return new PHPUnit_Framework_MockObject_Stub_ReturnArgument(
1891
-            $argumentIndex
1892
-        );
1893
-    }
1894
-
1895
-    /**
1896
-     * @param mixed $callback
1897
-     *
1898
-     * @return PHPUnit_Framework_MockObject_Stub_ReturnCallback
1899
-     */
1900
-    public static function returnCallback($callback)
1901
-    {
1902
-        return new PHPUnit_Framework_MockObject_Stub_ReturnCallback($callback);
1903
-    }
1904
-
1905
-    /**
1906
-     * Returns the current object.
1907
-     *
1908
-     * This method is useful when mocking a fluent interface.
1909
-     *
1910
-     * @return PHPUnit_Framework_MockObject_Stub_ReturnSelf
1911
-     */
1912
-    public static function returnSelf()
1913
-    {
1914
-        return new PHPUnit_Framework_MockObject_Stub_ReturnSelf();
1915
-    }
1916
-
1917
-    /**
1918
-     * @param Throwable $exception
1919
-     *
1920
-     * @return PHPUnit_Framework_MockObject_Stub_Exception
1921
-     */
1922
-    public static function throwException(Throwable $exception)
1923
-    {
1924
-        return new PHPUnit_Framework_MockObject_Stub_Exception($exception);
1925
-    }
1926
-
1927
-    /**
1928
-     * @param mixed $value , ...
1929
-     *
1930
-     * @return PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls
1931
-     */
1932
-    public static function onConsecutiveCalls()
1933
-    {
1934
-        $args = \func_get_args();
1935
-
1936
-        return new PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls($args);
1937
-    }
1938
-
1939
-    /**
1940
-     * @return bool
1941
-     */
1942
-    public function usesDataProvider()
1943
-    {
1944
-        return !empty($this->data);
1945
-    }
1946
-
1947
-    /**
1948
-     * @return string
1949
-     */
1950
-    public function dataDescription()
1951
-    {
1952
-        return \is_string($this->dataName) ? $this->dataName : '';
1953
-    }
1954
-
1955
-    public function registerComparator(Comparator $comparator)
1956
-    {
1957
-        ComparatorFactory::getInstance()->register($comparator);
1958
-
1959
-        $this->customComparators[] = $comparator;
1960
-    }
1961
-
1962
-    /**
1963
-     * Gets the data set description of a TestCase.
1964
-     *
1965
-     * @param bool $includeData
1966
-     *
1967
-     * @return string
1968
-     */
1969
-    public function getDataSetAsString($includeData = true)
1970
-    {
1971
-        $buffer = '';
1972
-
1973
-        if (!empty($this->data)) {
1974
-            if (\is_int($this->dataName)) {
1975
-                $buffer .= \sprintf(' with data set #%d', $this->dataName);
1976
-            } else {
1977
-                $buffer .= \sprintf(' with data set "%s"', $this->dataName);
1978
-            }
1979
-
1980
-            $exporter = new Exporter;
1981
-
1982
-            if ($includeData) {
1983
-                $buffer .= \sprintf(' (%s)', $exporter->shortenedRecursiveExport($this->data));
1984
-            }
1985
-        }
1986
-
1987
-        return $buffer;
1988
-    }
1989
-
1990
-    /**
1991
-     * Gets the data set of a TestCase.
1992
-     *
1993
-     * @return array
1994
-     */
1995
-    protected function getProvidedData()
1996
-    {
1997
-        return $this->data;
1998
-    }
1999
-
2000
-    /**
2001
-     * Creates a default TestResult object.
2002
-     *
2003
-     * @return TestResult
2004
-     */
2005
-    protected function createResult()
2006
-    {
2007
-        return new TestResult;
2008
-    }
2009
-
2010
-    protected function handleDependencies()
2011
-    {
2012
-        if (!empty($this->dependencies) && !$this->inIsolation) {
2013
-            $className  = \get_class($this);
2014
-            $passed     = $this->result->passed();
2015
-            $passedKeys = \array_keys($passed);
2016
-            $numKeys    = \count($passedKeys);
2017
-
2018
-            for ($i = 0; $i < $numKeys; $i++) {
2019
-                $pos = \strpos($passedKeys[$i], ' with data set');
2020
-
2021
-                if ($pos !== false) {
2022
-                    $passedKeys[$i] = \substr($passedKeys[$i], 0, $pos);
2023
-                }
2024
-            }
2025
-
2026
-            $passedKeys = \array_flip(\array_unique($passedKeys));
2027
-
2028
-            foreach ($this->dependencies as $dependency) {
2029
-                $clone = false;
2030
-
2031
-                if (\strpos($dependency, 'clone ') === 0) {
2032
-                    $clone      = true;
2033
-                    $dependency = \substr($dependency, \strlen('clone '));
2034
-                } elseif (\strpos($dependency, '!clone ') === 0) {
2035
-                    $clone      = false;
2036
-                    $dependency = \substr($dependency, \strlen('!clone '));
2037
-                }
2038
-
2039
-                if (\strpos($dependency, '::') === false) {
2040
-                    $dependency = $className . '::' . $dependency;
2041
-                }
2042
-
2043
-                if (!isset($passedKeys[$dependency])) {
2044
-                    $this->result->startTest($this);
2045
-                    $this->result->addError(
2046
-                        $this,
2047
-                        new SkippedTestError(
2048
-                            \sprintf(
2049
-                                'This test depends on "%s" to pass.',
2050
-                                $dependency
2051
-                            )
2052
-                        ),
2053
-                        0
2054
-                    );
2055
-                    $this->result->endTest($this, 0);
2056
-
2057
-                    return false;
2058
-                }
2059
-
2060
-                if (isset($passed[$dependency])) {
2061
-                    if ($passed[$dependency]['size'] != \PHPUnit\Util\Test::UNKNOWN &&
2062
-                        $this->getSize() != \PHPUnit\Util\Test::UNKNOWN &&
2063
-                        $passed[$dependency]['size'] > $this->getSize()) {
2064
-                        $this->result->addError(
2065
-                            $this,
2066
-                            new SkippedTestError(
2067
-                                'This test depends on a test that is larger than itself.'
2068
-                            ),
2069
-                            0
2070
-                        );
2071
-
2072
-                        return false;
2073
-                    }
2074
-
2075
-                    if ($clone) {
2076
-                        $deepCopy = new DeepCopy;
2077
-                        $deepCopy->skipUncloneable(false);
2078
-
2079
-                        $this->dependencyInput[$dependency] = $deepCopy->copy($passed[$dependency]['result']);
2080
-                    } else {
2081
-                        $this->dependencyInput[$dependency] = $passed[$dependency]['result'];
2082
-                    }
2083
-                } else {
2084
-                    $this->dependencyInput[$dependency] = null;
2085
-                }
2086
-            }
2087
-        }
2088
-
2089
-        return true;
2090
-    }
2091
-
2092
-    /**
2093
-     * This method is called before the first test of this test class is run.
2094
-     */
2095
-    public static function setUpBeforeClass()
2096
-    {
2097
-    }
2098
-
2099
-    /**
2100
-     * Sets up the fixture, for example, open a network connection.
2101
-     * This method is called before a test is executed.
2102
-     */
2103
-    protected function setUp()
2104
-    {
2105
-    }
2106
-
2107
-    /**
2108
-     * Performs assertions shared by all tests of a test case.
2109
-     *
2110
-     * This method is called before the execution of a test starts
2111
-     * and after setUp() is called.
2112
-     */
2113
-    protected function assertPreConditions()
2114
-    {
2115
-    }
2116
-
2117
-    /**
2118
-     * Performs assertions shared by all tests of a test case.
2119
-     *
2120
-     * This method is called after the execution of a test ends
2121
-     * and before tearDown() is called.
2122
-     */
2123
-    protected function assertPostConditions()
2124
-    {
2125
-    }
2126
-
2127
-    /**
2128
-     * Tears down the fixture, for example, close a network connection.
2129
-     * This method is called after a test is executed.
2130
-     */
2131
-    protected function tearDown()
2132
-    {
2133
-    }
2134
-
2135
-    /**
2136
-     * This method is called after the last test of this test class is run.
2137
-     */
2138
-    public static function tearDownAfterClass()
2139
-    {
2140
-    }
2141
-
2142
-    /**
2143
-     * This method is called when a test method did not execute successfully.
2144
-     *
2145
-     * @param Throwable $t
2146
-     *
2147
-     * @throws Throwable
2148
-     */
2149
-    protected function onNotSuccessfulTest(Throwable $t)
2150
-    {
2151
-        throw $t;
2152
-    }
2153
-
2154
-    /**
2155
-     * Performs custom preparations on the process isolation template.
2156
-     *
2157
-     * @param Text_Template $template
2158
-     */
2159
-    protected function prepareTemplate(Text_Template $template)
2160
-    {
2161
-    }
2162
-
2163
-    /**
2164
-     * Get the mock object generator, creating it if it doesn't exist.
2165
-     *
2166
-     * @return PHPUnit_Framework_MockObject_Generator
2167
-     */
2168
-    private function getMockObjectGenerator()
2169
-    {
2170
-        if (null === $this->mockObjectGenerator) {
2171
-            $this->mockObjectGenerator = new PHPUnit_Framework_MockObject_Generator;
2172
-        }
2173
-
2174
-        return $this->mockObjectGenerator;
2175
-    }
2176
-
2177
-    private function startOutputBuffering()
2178
-    {
2179
-        \ob_start();
2180
-
2181
-        $this->outputBufferingActive = true;
2182
-        $this->outputBufferingLevel  = \ob_get_level();
2183
-    }
2184
-
2185
-    private function stopOutputBuffering()
2186
-    {
2187
-        if (\ob_get_level() != $this->outputBufferingLevel) {
2188
-            while (\ob_get_level() >= $this->outputBufferingLevel) {
2189
-                \ob_end_clean();
2190
-            }
2191
-
2192
-            throw new RiskyTestError(
2193
-                'Test code or tested code did not (only) close its own output buffers'
2194
-            );
2195
-        }
2196
-
2197
-        $output = \ob_get_contents();
2198
-
2199
-        if ($this->outputCallback === false) {
2200
-            $this->output = $output;
2201
-        } else {
2202
-            $this->output = \call_user_func_array(
2203
-                $this->outputCallback,
2204
-                [$output]
2205
-            );
2206
-        }
2207
-
2208
-        \ob_end_clean();
2209
-
2210
-        $this->outputBufferingActive = false;
2211
-        $this->outputBufferingLevel  = \ob_get_level();
2212
-    }
2213
-
2214
-    private function snapshotGlobalState()
2215
-    {
2216
-        if ($this->runTestInSeparateProcess ||
2217
-            $this->inIsolation ||
2218
-            (!$this->backupGlobals === true && !$this->backupStaticAttributes)) {
2219
-            return;
2220
-        }
2221
-
2222
-        $this->snapshot = $this->createGlobalStateSnapshot($this->backupGlobals === true);
2223
-    }
2224
-
2225
-    private function restoreGlobalState()
2226
-    {
2227
-        if (!$this->snapshot instanceof Snapshot) {
2228
-            return;
2229
-        }
2230
-
2231
-        if ($this->beStrictAboutChangesToGlobalState) {
2232
-            try {
2233
-                $this->compareGlobalStateSnapshots(
2234
-                    $this->snapshot,
2235
-                    $this->createGlobalStateSnapshot($this->backupGlobals === true)
2236
-                );
2237
-            } catch (RiskyTestError $rte) {
2238
-                // Intentionally left empty
2239
-            }
2240
-        }
2241
-
2242
-        $restorer = new Restorer;
2243
-
2244
-        if ($this->backupGlobals === true) {
2245
-            $restorer->restoreGlobalVariables($this->snapshot);
2246
-        }
2247
-
2248
-        if ($this->backupStaticAttributes) {
2249
-            $restorer->restoreStaticAttributes($this->snapshot);
2250
-        }
2251
-
2252
-        $this->snapshot = null;
2253
-
2254
-        if (isset($rte)) {
2255
-            throw $rte;
2256
-        }
2257
-    }
2258
-
2259
-    /**
2260
-     * @param bool $backupGlobals
2261
-     *
2262
-     * @return Snapshot
2263
-     */
2264
-    private function createGlobalStateSnapshot($backupGlobals)
2265
-    {
2266
-        $blacklist = new Blacklist;
2267
-
2268
-        foreach ($this->backupGlobalsBlacklist as $globalVariable) {
2269
-            $blacklist->addGlobalVariable($globalVariable);
2270
-        }
2271
-
2272
-        if (!\defined('PHPUNIT_TESTSUITE')) {
2273
-            $blacklist->addClassNamePrefix('PHPUnit');
2274
-            $blacklist->addClassNamePrefix('File_Iterator');
2275
-            $blacklist->addClassNamePrefix('SebastianBergmann\CodeCoverage');
2276
-            $blacklist->addClassNamePrefix('PHP_Invoker');
2277
-            $blacklist->addClassNamePrefix('PHP_Timer');
2278
-            $blacklist->addClassNamePrefix('PHP_Token');
2279
-            $blacklist->addClassNamePrefix('Symfony');
2280
-            $blacklist->addClassNamePrefix('Text_Template');
2281
-            $blacklist->addClassNamePrefix('Doctrine\Instantiator');
2282
-            $blacklist->addClassNamePrefix('Prophecy');
2283
-
2284
-            foreach ($this->backupStaticAttributesBlacklist as $class => $attributes) {
2285
-                foreach ($attributes as $attribute) {
2286
-                    $blacklist->addStaticAttribute($class, $attribute);
2287
-                }
2288
-            }
2289
-        }
2290
-
2291
-        return new Snapshot(
2292
-            $blacklist,
2293
-            $backupGlobals,
2294
-            (bool) $this->backupStaticAttributes,
2295
-            false,
2296
-            false,
2297
-            false,
2298
-            false,
2299
-            false,
2300
-            false,
2301
-            false
2302
-        );
2303
-    }
2304
-
2305
-    /**
2306
-     * @param Snapshot $before
2307
-     * @param Snapshot $after
2308
-     *
2309
-     * @throws RiskyTestError
2310
-     */
2311
-    private function compareGlobalStateSnapshots(Snapshot $before, Snapshot $after)
2312
-    {
2313
-        $backupGlobals = $this->backupGlobals === null || $this->backupGlobals === true;
2314
-
2315
-        if ($backupGlobals) {
2316
-            $this->compareGlobalStateSnapshotPart(
2317
-                $before->globalVariables(),
2318
-                $after->globalVariables(),
2319
-                "--- Global variables before the test\n+++ Global variables after the test\n"
2320
-            );
2321
-
2322
-            $this->compareGlobalStateSnapshotPart(
2323
-                $before->superGlobalVariables(),
2324
-                $after->superGlobalVariables(),
2325
-                "--- Super-global variables before the test\n+++ Super-global variables after the test\n"
2326
-            );
2327
-        }
2328
-
2329
-        if ($this->backupStaticAttributes) {
2330
-            $this->compareGlobalStateSnapshotPart(
2331
-                $before->staticAttributes(),
2332
-                $after->staticAttributes(),
2333
-                "--- Static attributes before the test\n+++ Static attributes after the test\n"
2334
-            );
2335
-        }
2336
-    }
2337
-
2338
-    /**
2339
-     * @param array  $before
2340
-     * @param array  $after
2341
-     * @param string $header
2342
-     *
2343
-     * @throws RiskyTestError
2344
-     */
2345
-    private function compareGlobalStateSnapshotPart(array $before, array $after, $header)
2346
-    {
2347
-        if ($before != $after) {
2348
-            $differ   = new Differ($header);
2349
-            $exporter = new Exporter;
2350
-
2351
-            $diff = $differ->diff(
2352
-                $exporter->export($before),
2353
-                $exporter->export($after)
2354
-            );
2355
-
2356
-            throw new RiskyTestError(
2357
-                $diff
2358
-            );
2359
-        }
2360
-    }
2361
-
2362
-    /**
2363
-     * @return Prophecy\Prophet
2364
-     */
2365
-    private function getProphet()
2366
-    {
2367
-        if ($this->prophet === null) {
2368
-            $this->prophet = new Prophet;
2369
-        }
2370
-
2371
-        return $this->prophet;
2372
-    }
2373
-
2374
-    /**
2375
-     * @param PHPUnit_Framework_MockObject_MockObject $mock
2376
-     *
2377
-     * @return bool
2378
-     */
2379
-    private function shouldInvocationMockerBeReset(PHPUnit_Framework_MockObject_MockObject $mock)
2380
-    {
2381
-        $enumerator = new Enumerator;
2382
-
2383
-        foreach ($enumerator->enumerate($this->dependencyInput) as $object) {
2384
-            if ($mock === $object) {
2385
-                return false;
2386
-            }
2387
-        }
2388
-
2389
-        if (!\is_array($this->testResult) && !\is_object($this->testResult)) {
2390
-            return true;
2391
-        }
2392
-
2393
-        foreach ($enumerator->enumerate($this->testResult) as $object) {
2394
-            if ($mock === $object) {
2395
-                return false;
2396
-            }
2397
-        }
2398
-
2399
-        return true;
2400
-    }
2401
-
2402
-    /**
2403
-     * @param array $testArguments
2404
-     * @param array $visited
2405
-     */
2406
-    private function registerMockObjectsFromTestArguments(array $testArguments, array &$visited = [])
2407
-    {
2408
-        if ($this->registerMockObjectsFromTestArgumentsRecursively) {
2409
-            $enumerator = new Enumerator;
2410
-
2411
-            foreach ($enumerator->enumerate($testArguments) as $object) {
2412
-                if ($object instanceof PHPUnit_Framework_MockObject_MockObject) {
2413
-                    $this->registerMockObject($object);
2414
-                }
2415
-            }
2416
-        } else {
2417
-            foreach ($testArguments as $testArgument) {
2418
-                if ($testArgument instanceof PHPUnit_Framework_MockObject_MockObject) {
2419
-                    if ($this->isCloneable($testArgument)) {
2420
-                        $testArgument = clone $testArgument;
2421
-                    }
2422
-
2423
-                    $this->registerMockObject($testArgument);
2424
-                } elseif (\is_array($testArgument) && !\in_array($testArgument, $visited, true)) {
2425
-                    $visited[] = $testArgument;
2426
-
2427
-                    $this->registerMockObjectsFromTestArguments(
2428
-                        $testArgument,
2429
-                        $visited
2430
-                    );
2431
-                }
2432
-            }
2433
-        }
2434
-    }
2435
-
2436
-    private function setDoesNotPerformAssertionsFromAnnotation()
2437
-    {
2438
-        $annotations = $this->getAnnotations();
2439
-
2440
-        if (isset($annotations['method']['doesNotPerformAssertions'])) {
2441
-            $this->doesNotPerformAssertions = true;
2442
-        }
2443
-    }
2444
-
2445
-    /**
2446
-     * @param PHPUnit_Framework_MockObject_MockObject $testArgument
2447
-     *
2448
-     * @return bool
2449
-     */
2450
-    private function isCloneable(PHPUnit_Framework_MockObject_MockObject $testArgument)
2451
-    {
2452
-        $reflector = new ReflectionObject($testArgument);
2453
-
2454
-        if (!$reflector->isCloneable()) {
2455
-            return false;
2456
-        }
2457
-
2458
-        if ($reflector->hasMethod('__clone') &&
2459
-            $reflector->getMethod('__clone')->isPublic()) {
2460
-            return true;
2461
-        }
2462
-
2463
-        return false;
2464
-    }
2465
-
2466
-    private function unregisterCustomComparators()
2467
-    {
2468
-        $factory = ComparatorFactory::getInstance();
2469
-
2470
-        foreach ($this->customComparators as $comparator) {
2471
-            $factory->unregister($comparator);
2472
-        }
2473
-
2474
-        $this->customComparators = [];
2475
-    }
2476
-
2477
-    private function cleanupIniSettings()
2478
-    {
2479
-        foreach ($this->iniSettings as $varName => $oldValue) {
2480
-            \ini_set($varName, $oldValue);
2481
-        }
2482
-
2483
-        $this->iniSettings = [];
2484
-    }
2485
-
2486
-    private function cleanupLocaleSettings()
2487
-    {
2488
-        foreach ($this->locale as $category => $locale) {
2489
-            \setlocale($category, $locale);
2490
-        }
2491
-
2492
-        $this->locale = [];
2493
-    }
2494
-
2495
-    private function checkExceptionExpectations(Throwable $throwable): bool
2496
-    {
2497
-        $result = false;
2498
-
2499
-        if ($this->expectedException !== null || $this->expectedExceptionCode !== null || $this->expectedExceptionMessage !== null || $this->expectedExceptionMessageRegExp !== null) {
2500
-            $result = true;
2501
-        }
2502
-
2503
-        if ($throwable instanceof Exception) {
2504
-            $result = false;
2505
-        }
2506
-
2507
-        if (\is_string($this->expectedException)) {
2508
-            $reflector = new ReflectionClass($this->expectedException);
2509
-
2510
-            if ($this->expectedException === 'PHPUnit\Framework\Exception' ||
2511
-                $this->expectedException === '\PHPUnit\Framework\Exception' ||
2512
-                $reflector->isSubclassOf('PHPUnit\Framework\Exception')) {
2513
-                $result = true;
2514
-            }
2515
-        }
2516
-
2517
-        return $result;
2518
-    }
103
+	/**
104
+	 * Enable or disable the backup and restoration of the $GLOBALS array.
105
+	 * Overwrite this attribute in a child class of TestCase.
106
+	 * Setting this attribute in setUp() has no effect!
107
+	 *
108
+	 * @var bool
109
+	 */
110
+	protected $backupGlobals;
111
+
112
+	/**
113
+	 * @var array
114
+	 */
115
+	protected $backupGlobalsBlacklist = [];
116
+
117
+	/**
118
+	 * Enable or disable the backup and restoration of static attributes.
119
+	 * Overwrite this attribute in a child class of TestCase.
120
+	 * Setting this attribute in setUp() has no effect!
121
+	 *
122
+	 * @var bool
123
+	 */
124
+	protected $backupStaticAttributes;
125
+
126
+	/**
127
+	 * @var array
128
+	 */
129
+	protected $backupStaticAttributesBlacklist = [];
130
+
131
+	/**
132
+	 * Whether or not this test is to be run in a separate PHP process.
133
+	 *
134
+	 * @var bool
135
+	 */
136
+	protected $runTestInSeparateProcess;
137
+
138
+	/**
139
+	 * Whether or not this class is to be run in a separate PHP process.
140
+	 *
141
+	 * @var bool
142
+	 */
143
+	private $runClassInSeparateProcess;
144
+
145
+	/**
146
+	 * Whether or not this test should preserve the global state when
147
+	 * running in a separate PHP process.
148
+	 *
149
+	 * @var bool
150
+	 */
151
+	protected $preserveGlobalState = true;
152
+
153
+	/**
154
+	 * Whether or not this test is running in a separate PHP process.
155
+	 *
156
+	 * @var bool
157
+	 */
158
+	private $inIsolation = false;
159
+
160
+	/**
161
+	 * @var array
162
+	 */
163
+	private $data;
164
+
165
+	/**
166
+	 * @var string
167
+	 */
168
+	private $dataName;
169
+
170
+	/**
171
+	 * @var bool
172
+	 */
173
+	private $useErrorHandler;
174
+
175
+	/**
176
+	 * The name of the expected Exception.
177
+	 *
178
+	 * @var null|string
179
+	 */
180
+	private $expectedException;
181
+
182
+	/**
183
+	 * The message of the expected Exception.
184
+	 *
185
+	 * @var string
186
+	 */
187
+	private $expectedExceptionMessage;
188
+
189
+	/**
190
+	 * The regex pattern to validate the expected Exception message.
191
+	 *
192
+	 * @var string
193
+	 */
194
+	private $expectedExceptionMessageRegExp;
195
+
196
+	/**
197
+	 * The code of the expected Exception.
198
+	 *
199
+	 * @var null|int|string
200
+	 */
201
+	private $expectedExceptionCode;
202
+
203
+	/**
204
+	 * The name of the test case.
205
+	 *
206
+	 * @var string
207
+	 */
208
+	private $name;
209
+
210
+	/**
211
+	 * @var string[]
212
+	 */
213
+	private $dependencies = [];
214
+
215
+	/**
216
+	 * @var array
217
+	 */
218
+	private $dependencyInput = [];
219
+
220
+	/**
221
+	 * @var array
222
+	 */
223
+	private $iniSettings = [];
224
+
225
+	/**
226
+	 * @var array
227
+	 */
228
+	private $locale = [];
229
+
230
+	/**
231
+	 * @var array
232
+	 */
233
+	private $mockObjects = [];
234
+
235
+	/**
236
+	 * @var array
237
+	 */
238
+	private $mockObjectGenerator;
239
+
240
+	/**
241
+	 * @var int
242
+	 */
243
+	private $status;
244
+
245
+	/**
246
+	 * @var string
247
+	 */
248
+	private $statusMessage = '';
249
+
250
+	/**
251
+	 * @var int
252
+	 */
253
+	private $numAssertions = 0;
254
+
255
+	/**
256
+	 * @var TestResult
257
+	 */
258
+	private $result;
259
+
260
+	/**
261
+	 * @var mixed
262
+	 */
263
+	private $testResult;
264
+
265
+	/**
266
+	 * @var string
267
+	 */
268
+	private $output = '';
269
+
270
+	/**
271
+	 * @var string
272
+	 */
273
+	private $outputExpectedRegex;
274
+
275
+	/**
276
+	 * @var string
277
+	 */
278
+	private $outputExpectedString;
279
+
280
+	/**
281
+	 * @var mixed
282
+	 */
283
+	private $outputCallback = false;
284
+
285
+	/**
286
+	 * @var bool
287
+	 */
288
+	private $outputBufferingActive = false;
289
+
290
+	/**
291
+	 * @var int
292
+	 */
293
+	private $outputBufferingLevel;
294
+
295
+	/**
296
+	 * @var SebastianBergmann\GlobalState\Snapshot
297
+	 */
298
+	private $snapshot;
299
+
300
+	/**
301
+	 * @var Prophecy\Prophet
302
+	 */
303
+	private $prophet;
304
+
305
+	/**
306
+	 * @var bool
307
+	 */
308
+	private $beStrictAboutChangesToGlobalState = false;
309
+
310
+	/**
311
+	 * @var bool
312
+	 */
313
+	private $registerMockObjectsFromTestArgumentsRecursively = false;
314
+
315
+	/**
316
+	 * @var string[]
317
+	 */
318
+	private $warnings = [];
319
+
320
+	/**
321
+	 * @var array
322
+	 */
323
+	private $groups = [];
324
+
325
+	/**
326
+	 * @var bool
327
+	 */
328
+	private $doesNotPerformAssertions = false;
329
+
330
+	/**
331
+	 * @var Comparator[]
332
+	 */
333
+	private $customComparators = [];
334
+
335
+	/**
336
+	 * Constructs a test case with the given name.
337
+	 *
338
+	 * @param string $name
339
+	 * @param array  $data
340
+	 * @param string $dataName
341
+	 */
342
+	public function __construct($name = null, array $data = [], $dataName = '')
343
+	{
344
+		if ($name !== null) {
345
+			$this->setName($name);
346
+		}
347
+
348
+		$this->data     = $data;
349
+		$this->dataName = $dataName;
350
+	}
351
+
352
+	/**
353
+	 * Returns a string representation of the test case.
354
+	 *
355
+	 * @return string
356
+	 */
357
+	public function toString()
358
+	{
359
+		$class = new ReflectionClass($this);
360
+
361
+		$buffer = \sprintf(
362
+			'%s::%s',
363
+			$class->name,
364
+			$this->getName(false)
365
+		);
366
+
367
+		return $buffer . $this->getDataSetAsString();
368
+	}
369
+
370
+	/**
371
+	 * Counts the number of test cases executed by run(TestResult result).
372
+	 *
373
+	 * @return int
374
+	 */
375
+	public function count()
376
+	{
377
+		return 1;
378
+	}
379
+
380
+	public function getGroups()
381
+	{
382
+		return $this->groups;
383
+	}
384
+
385
+	/**
386
+	 * @param array $groups
387
+	 */
388
+	public function setGroups(array $groups)
389
+	{
390
+		$this->groups = $groups;
391
+	}
392
+
393
+	/**
394
+	 * Returns the annotations for this test.
395
+	 *
396
+	 * @return array
397
+	 */
398
+	public function getAnnotations()
399
+	{
400
+		return \PHPUnit\Util\Test::parseTestMethodAnnotations(
401
+			\get_class($this),
402
+			$this->name
403
+		);
404
+	}
405
+
406
+	/**
407
+	 * Gets the name of a TestCase.
408
+	 *
409
+	 * @param bool $withDataSet
410
+	 *
411
+	 * @return string
412
+	 */
413
+	public function getName($withDataSet = true)
414
+	{
415
+		if ($withDataSet) {
416
+			return $this->name . $this->getDataSetAsString(false);
417
+		}
418
+
419
+		return $this->name;
420
+	}
421
+
422
+	/**
423
+	 * Returns the size of the test.
424
+	 *
425
+	 * @return int
426
+	 */
427
+	public function getSize()
428
+	{
429
+		return \PHPUnit\Util\Test::getSize(
430
+			\get_class($this),
431
+			$this->getName(false)
432
+		);
433
+	}
434
+
435
+	/**
436
+	 * @return bool
437
+	 */
438
+	public function hasSize()
439
+	{
440
+		return $this->getSize() !== \PHPUnit\Util\Test::UNKNOWN;
441
+	}
442
+
443
+	/**
444
+	 * @return bool
445
+	 */
446
+	public function isSmall()
447
+	{
448
+		return $this->getSize() === \PHPUnit\Util\Test::SMALL;
449
+	}
450
+
451
+	/**
452
+	 * @return bool
453
+	 */
454
+	public function isMedium()
455
+	{
456
+		return $this->getSize() === \PHPUnit\Util\Test::MEDIUM;
457
+	}
458
+
459
+	/**
460
+	 * @return bool
461
+	 */
462
+	public function isLarge()
463
+	{
464
+		return $this->getSize() === \PHPUnit\Util\Test::LARGE;
465
+	}
466
+
467
+	/**
468
+	 * @return string
469
+	 */
470
+	public function getActualOutput()
471
+	{
472
+		if (!$this->outputBufferingActive) {
473
+			return $this->output;
474
+		}
475
+
476
+		return \ob_get_contents();
477
+	}
478
+
479
+	/**
480
+	 * @return bool
481
+	 */
482
+	public function hasOutput()
483
+	{
484
+		if (\strlen($this->output) === 0) {
485
+			return false;
486
+		}
487
+
488
+		if ($this->hasExpectationOnOutput()) {
489
+			return false;
490
+		}
491
+
492
+		return true;
493
+	}
494
+
495
+	/**
496
+	 * @return bool
497
+	 */
498
+	public function doesNotPerformAssertions()
499
+	{
500
+		return $this->doesNotPerformAssertions;
501
+	}
502
+
503
+	/**
504
+	 * @param string $expectedRegex
505
+	 *
506
+	 * @throws Exception
507
+	 */
508
+	public function expectOutputRegex($expectedRegex)
509
+	{
510
+		if ($this->outputExpectedString !== null) {
511
+			throw new Exception;
512
+		}
513
+
514
+		if (\is_string($expectedRegex) || null === $expectedRegex) {
515
+			$this->outputExpectedRegex = $expectedRegex;
516
+		}
517
+	}
518
+
519
+	/**
520
+	 * @param string $expectedString
521
+	 */
522
+	public function expectOutputString($expectedString)
523
+	{
524
+		if ($this->outputExpectedRegex !== null) {
525
+			throw new Exception;
526
+		}
527
+
528
+		if (\is_string($expectedString) || null === $expectedString) {
529
+			$this->outputExpectedString = $expectedString;
530
+		}
531
+	}
532
+
533
+	/**
534
+	 * @return bool
535
+	 */
536
+	public function hasExpectationOnOutput()
537
+	{
538
+		return \is_string($this->outputExpectedString) || \is_string($this->outputExpectedRegex);
539
+	}
540
+
541
+	/**
542
+	 * @return null|string
543
+	 */
544
+	public function getExpectedException()
545
+	{
546
+		return $this->expectedException;
547
+	}
548
+
549
+	/**
550
+	 * @return null|int|string
551
+	 */
552
+	public function getExpectedExceptionCode()
553
+	{
554
+		return $this->expectedExceptionCode;
555
+	}
556
+
557
+	/**
558
+	 * @return string
559
+	 */
560
+	public function getExpectedExceptionMessage()
561
+	{
562
+		return $this->expectedExceptionMessage;
563
+	}
564
+
565
+	/**
566
+	 * @return string
567
+	 */
568
+	public function getExpectedExceptionMessageRegExp()
569
+	{
570
+		return $this->expectedExceptionMessageRegExp;
571
+	}
572
+
573
+	/**
574
+	 * @param string $exception
575
+	 */
576
+	public function expectException($exception)
577
+	{
578
+		if (!\is_string($exception)) {
579
+			throw InvalidArgumentHelper::factory(1, 'string');
580
+		}
581
+
582
+		$this->expectedException = $exception;
583
+	}
584
+
585
+	/**
586
+	 * @param int|string $code
587
+	 *
588
+	 * @throws Exception
589
+	 */
590
+	public function expectExceptionCode($code)
591
+	{
592
+		if (!\is_int($code) && !\is_string($code)) {
593
+			throw InvalidArgumentHelper::factory(1, 'integer or string');
594
+		}
595
+
596
+		$this->expectedExceptionCode = $code;
597
+	}
598
+
599
+	/**
600
+	 * @param string $message
601
+	 *
602
+	 * @throws Exception
603
+	 */
604
+	public function expectExceptionMessage($message)
605
+	{
606
+		if (!\is_string($message)) {
607
+			throw InvalidArgumentHelper::factory(1, 'string');
608
+		}
609
+
610
+		$this->expectedExceptionMessage = $message;
611
+	}
612
+
613
+	/**
614
+	 * @param string $messageRegExp
615
+	 *
616
+	 * @throws Exception
617
+	 */
618
+	public function expectExceptionMessageRegExp($messageRegExp)
619
+	{
620
+		if (!\is_string($messageRegExp)) {
621
+			throw InvalidArgumentHelper::factory(1, 'string');
622
+		}
623
+
624
+		$this->expectedExceptionMessageRegExp = $messageRegExp;
625
+	}
626
+
627
+	/**
628
+	 * Sets up an expectation for an exception to be raised by the code under test.
629
+	 * Information for expected exception class, expected exception message, and
630
+	 * expected exception code are retrieved from a given Exception object.
631
+	 */
632
+	public function expectExceptionObject(\Exception $exception)
633
+	{
634
+		$this->expectException(\get_class($exception));
635
+		$this->expectExceptionMessage($exception->getMessage());
636
+		$this->expectExceptionCode($exception->getCode());
637
+	}
638
+
639
+	/**
640
+	 * @param bool $flag
641
+	 */
642
+	public function setRegisterMockObjectsFromTestArgumentsRecursively($flag)
643
+	{
644
+		if (!\is_bool($flag)) {
645
+			throw InvalidArgumentHelper::factory(1, 'boolean');
646
+		}
647
+
648
+		$this->registerMockObjectsFromTestArgumentsRecursively = $flag;
649
+	}
650
+
651
+	protected function setExpectedExceptionFromAnnotation()
652
+	{
653
+		try {
654
+			$expectedException = \PHPUnit\Util\Test::getExpectedException(
655
+				\get_class($this),
656
+				$this->name
657
+			);
658
+
659
+			if ($expectedException !== false) {
660
+				$this->expectException($expectedException['class']);
661
+
662
+				if ($expectedException['code'] !== null) {
663
+					$this->expectExceptionCode($expectedException['code']);
664
+				}
665
+
666
+				if ($expectedException['message'] !== '') {
667
+					$this->expectExceptionMessage($expectedException['message']);
668
+				} elseif ($expectedException['message_regex'] !== '') {
669
+					$this->expectExceptionMessageRegExp($expectedException['message_regex']);
670
+				}
671
+			}
672
+		} catch (ReflectionException $e) {
673
+		}
674
+	}
675
+
676
+	/**
677
+	 * @param bool $useErrorHandler
678
+	 */
679
+	public function setUseErrorHandler($useErrorHandler)
680
+	{
681
+		$this->useErrorHandler = $useErrorHandler;
682
+	}
683
+
684
+	protected function setUseErrorHandlerFromAnnotation()
685
+	{
686
+		try {
687
+			$useErrorHandler = \PHPUnit\Util\Test::getErrorHandlerSettings(
688
+				\get_class($this),
689
+				$this->name
690
+			);
691
+
692
+			if ($useErrorHandler !== null) {
693
+				$this->setUseErrorHandler($useErrorHandler);
694
+			}
695
+		} catch (ReflectionException $e) {
696
+		}
697
+	}
698
+
699
+	protected function checkRequirements()
700
+	{
701
+		if (!$this->name || !\method_exists($this, $this->name)) {
702
+			return;
703
+		}
704
+
705
+		$missingRequirements = \PHPUnit\Util\Test::getMissingRequirements(
706
+			\get_class($this),
707
+			$this->name
708
+		);
709
+
710
+		if (!empty($missingRequirements)) {
711
+			$this->markTestSkipped(\implode(PHP_EOL, $missingRequirements));
712
+		}
713
+	}
714
+
715
+	/**
716
+	 * Returns the status of this test.
717
+	 *
718
+	 * @return int
719
+	 */
720
+	public function getStatus()
721
+	{
722
+		return $this->status;
723
+	}
724
+
725
+	public function markAsRisky()
726
+	{
727
+		$this->status = BaseTestRunner::STATUS_RISKY;
728
+	}
729
+
730
+	/**
731
+	 * Returns the status message of this test.
732
+	 *
733
+	 * @return string
734
+	 */
735
+	public function getStatusMessage()
736
+	{
737
+		return $this->statusMessage;
738
+	}
739
+
740
+	/**
741
+	 * Returns whether or not this test has failed.
742
+	 *
743
+	 * @return bool
744
+	 */
745
+	public function hasFailed()
746
+	{
747
+		$status = $this->getStatus();
748
+
749
+		return $status == BaseTestRunner::STATUS_FAILURE ||
750
+			$status == BaseTestRunner::STATUS_ERROR;
751
+	}
752
+
753
+	/**
754
+	 * Runs the test case and collects the results in a TestResult object.
755
+	 * If no TestResult object is passed a new one will be created.
756
+	 *
757
+	 * @param TestResult $result
758
+	 *
759
+	 * @return TestResult|null
760
+	 *
761
+	 * @throws Exception
762
+	 */
763
+	public function run(TestResult $result = null)
764
+	{
765
+		if ($result === null) {
766
+			$result = $this->createResult();
767
+		}
768
+
769
+		if (!$this instanceof WarningTestCase) {
770
+			$this->setTestResultObject($result);
771
+			$this->setUseErrorHandlerFromAnnotation();
772
+		}
773
+
774
+		if ($this->useErrorHandler !== null) {
775
+			$oldErrorHandlerSetting = $result->getConvertErrorsToExceptions();
776
+			$result->convertErrorsToExceptions($this->useErrorHandler);
777
+		}
778
+
779
+		if (!$this instanceof WarningTestCase &&
780
+			!$this instanceof SkippedTestCase &&
781
+			!$this->handleDependencies()) {
782
+			return;
783
+		}
784
+
785
+		$runEntireClass =  $this->runClassInSeparateProcess && !$this->runTestInSeparateProcess;
786
+
787
+		if (($this->runTestInSeparateProcess === true || $this->runClassInSeparateProcess === true) &&
788
+			$this->inIsolation !== true &&
789
+			!$this instanceof PhptTestCase) {
790
+			$class = new ReflectionClass($this);
791
+
792
+			if ($runEntireClass) {
793
+				$template = new Text_Template(
794
+					__DIR__ . '/../Util/PHP/Template/TestCaseClass.tpl'
795
+				);
796
+			} else {
797
+				$template = new Text_Template(
798
+					__DIR__ . '/../Util/PHP/Template/TestCaseMethod.tpl'
799
+				);
800
+			}
801
+
802
+			if ($this->preserveGlobalState) {
803
+				$constants     = GlobalState::getConstantsAsString();
804
+				$globals       = GlobalState::getGlobalsAsString();
805
+				$includedFiles = GlobalState::getIncludedFilesAsString();
806
+				$iniSettings   = GlobalState::getIniSettingsAsString();
807
+			} else {
808
+				$constants = '';
809
+				if (!empty($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
810
+					$globals = '$GLOBALS[\'__PHPUNIT_BOOTSTRAP\'] = ' . \var_export($GLOBALS['__PHPUNIT_BOOTSTRAP'], true) . ";\n";
811
+				} else {
812
+					$globals = '';
813
+				}
814
+				$includedFiles = '';
815
+				$iniSettings   = '';
816
+			}
817
+
818
+			$coverage                                   = $result->getCollectCodeCoverageInformation() ? 'true' : 'false';
819
+			$isStrictAboutTestsThatDoNotTestAnything    = $result->isStrictAboutTestsThatDoNotTestAnything() ? 'true' : 'false';
820
+			$isStrictAboutOutputDuringTests             = $result->isStrictAboutOutputDuringTests() ? 'true' : 'false';
821
+			$enforcesTimeLimit                          = $result->enforcesTimeLimit() ? 'true' : 'false';
822
+			$isStrictAboutTodoAnnotatedTests            = $result->isStrictAboutTodoAnnotatedTests() ? 'true' : 'false';
823
+			$isStrictAboutResourceUsageDuringSmallTests = $result->isStrictAboutResourceUsageDuringSmallTests() ? 'true' : 'false';
824
+
825
+			if (\defined('PHPUNIT_COMPOSER_INSTALL')) {
826
+				$composerAutoload = \var_export(PHPUNIT_COMPOSER_INSTALL, true);
827
+			} else {
828
+				$composerAutoload = '\'\'';
829
+			}
830
+
831
+			if (\defined('__PHPUNIT_PHAR__')) {
832
+				$phar = \var_export(__PHPUNIT_PHAR__, true);
833
+			} else {
834
+				$phar = '\'\'';
835
+			}
836
+
837
+			if ($result->getCodeCoverage()) {
838
+				$codeCoverageFilter = $result->getCodeCoverage()->filter();
839
+			} else {
840
+				$codeCoverageFilter = null;
841
+			}
842
+
843
+			$data               = \var_export(\serialize($this->data), true);
844
+			$dataName           = \var_export($this->dataName, true);
845
+			$dependencyInput    = \var_export(\serialize($this->dependencyInput), true);
846
+			$includePath        = \var_export(\get_include_path(), true);
847
+			$codeCoverageFilter = \var_export(\serialize($codeCoverageFilter), true);
848
+			// must do these fixes because TestCaseMethod.tpl has unserialize('{data}') in it, and we can't break BC
849
+			// the lines above used to use addcslashes() rather than var_export(), which breaks null byte escape sequences
850
+			$data               = "'." . $data . ".'";
851
+			$dataName           = "'.(" . $dataName . ").'";
852
+			$dependencyInput    = "'." . $dependencyInput . ".'";
853
+			$includePath        = "'." . $includePath . ".'";
854
+			$codeCoverageFilter = "'." . $codeCoverageFilter . ".'";
855
+
856
+			$configurationFilePath = $GLOBALS['__PHPUNIT_CONFIGURATION_FILE'] ?? '';
857
+
858
+			$var = [
859
+				'composerAutoload'                           => $composerAutoload,
860
+				'phar'                                       => $phar,
861
+				'filename'                                   => $class->getFileName(),
862
+				'className'                                  => $class->getName(),
863
+				'collectCodeCoverageInformation'             => $coverage,
864
+				'data'                                       => $data,
865
+				'dataName'                                   => $dataName,
866
+				'dependencyInput'                            => $dependencyInput,
867
+				'constants'                                  => $constants,
868
+				'globals'                                    => $globals,
869
+				'include_path'                               => $includePath,
870
+				'included_files'                             => $includedFiles,
871
+				'iniSettings'                                => $iniSettings,
872
+				'isStrictAboutTestsThatDoNotTestAnything'    => $isStrictAboutTestsThatDoNotTestAnything,
873
+				'isStrictAboutOutputDuringTests'             => $isStrictAboutOutputDuringTests,
874
+				'enforcesTimeLimit'                          => $enforcesTimeLimit,
875
+				'isStrictAboutTodoAnnotatedTests'            => $isStrictAboutTodoAnnotatedTests,
876
+				'isStrictAboutResourceUsageDuringSmallTests' => $isStrictAboutResourceUsageDuringSmallTests,
877
+				'codeCoverageFilter'                         => $codeCoverageFilter,
878
+				'configurationFilePath'                      => $configurationFilePath
879
+			];
880
+
881
+			if (!$runEntireClass) {
882
+				$var['methodName'] = $this->name;
883
+			}
884
+
885
+			$template->setVar(
886
+				$var
887
+			);
888
+
889
+			$this->prepareTemplate($template);
890
+
891
+			$php = AbstractPhpProcess::factory();
892
+			$php->runTestJob($template->render(), $this, $result);
893
+		} else {
894
+			$result->run($this);
895
+		}
896
+
897
+		if (isset($oldErrorHandlerSetting)) {
898
+			$result->convertErrorsToExceptions($oldErrorHandlerSetting);
899
+		}
900
+
901
+		$this->result = null;
902
+
903
+		return $result;
904
+	}
905
+
906
+	/**
907
+	 * Runs the bare test sequence.
908
+	 */
909
+	public function runBare()
910
+	{
911
+		$this->numAssertions = 0;
912
+
913
+		$this->snapshotGlobalState();
914
+		$this->startOutputBuffering();
915
+		\clearstatcache();
916
+		$currentWorkingDirectory = \getcwd();
917
+
918
+		$hookMethods = \PHPUnit\Util\Test::getHookMethods(\get_class($this));
919
+
920
+		try {
921
+			$hasMetRequirements = false;
922
+			$this->checkRequirements();
923
+			$hasMetRequirements = true;
924
+
925
+			if ($this->inIsolation) {
926
+				foreach ($hookMethods['beforeClass'] as $method) {
927
+					$this->$method();
928
+				}
929
+			}
930
+
931
+			$this->setExpectedExceptionFromAnnotation();
932
+			$this->setDoesNotPerformAssertionsFromAnnotation();
933
+
934
+			foreach ($hookMethods['before'] as $method) {
935
+				$this->$method();
936
+			}
937
+
938
+			$this->assertPreConditions();
939
+			$this->testResult = $this->runTest();
940
+			$this->verifyMockObjects();
941
+			$this->assertPostConditions();
942
+
943
+			if (!empty($this->warnings)) {
944
+				throw new Warning(
945
+					\implode(
946
+						"\n",
947
+						\array_unique($this->warnings)
948
+					)
949
+				);
950
+			}
951
+
952
+			$this->status = BaseTestRunner::STATUS_PASSED;
953
+		} catch (IncompleteTest $e) {
954
+			$this->status        = BaseTestRunner::STATUS_INCOMPLETE;
955
+			$this->statusMessage = $e->getMessage();
956
+		} catch (SkippedTest $e) {
957
+			$this->status        = BaseTestRunner::STATUS_SKIPPED;
958
+			$this->statusMessage = $e->getMessage();
959
+		} catch (Warning $e) {
960
+			$this->status        = BaseTestRunner::STATUS_WARNING;
961
+			$this->statusMessage = $e->getMessage();
962
+		} catch (AssertionFailedError $e) {
963
+			$this->status        = BaseTestRunner::STATUS_FAILURE;
964
+			$this->statusMessage = $e->getMessage();
965
+		} catch (PredictionException $e) {
966
+			$this->status        = BaseTestRunner::STATUS_FAILURE;
967
+			$this->statusMessage = $e->getMessage();
968
+		} catch (Throwable $_e) {
969
+			$e = $_e;
970
+		}
971
+
972
+		if (isset($_e)) {
973
+			$this->status        = BaseTestRunner::STATUS_ERROR;
974
+			$this->statusMessage = $_e->getMessage();
975
+		}
976
+
977
+		// Clean up the mock objects.
978
+		$this->mockObjects = [];
979
+		$this->prophet     = null;
980
+
981
+		// Tear down the fixture. An exception raised in tearDown() will be
982
+		// caught and passed on when no exception was raised before.
983
+		try {
984
+			if ($hasMetRequirements) {
985
+				foreach ($hookMethods['after'] as $method) {
986
+					$this->$method();
987
+				}
988
+
989
+				if ($this->inIsolation) {
990
+					foreach ($hookMethods['afterClass'] as $method) {
991
+						$this->$method();
992
+					}
993
+				}
994
+			}
995
+		} catch (Throwable $_e) {
996
+			if (!isset($e)) {
997
+				$e = $_e;
998
+			}
999
+		}
1000
+
1001
+		try {
1002
+			$this->stopOutputBuffering();
1003
+		} catch (RiskyTestError $_e) {
1004
+			if (!isset($e)) {
1005
+				$e = $_e;
1006
+			}
1007
+		}
1008
+
1009
+		\clearstatcache();
1010
+
1011
+		if ($currentWorkingDirectory != \getcwd()) {
1012
+			\chdir($currentWorkingDirectory);
1013
+		}
1014
+
1015
+		$this->restoreGlobalState();
1016
+		$this->unregisterCustomComparators();
1017
+		$this->cleanupIniSettings();
1018
+		$this->cleanupLocaleSettings();
1019
+
1020
+		// Perform assertion on output.
1021
+		if (!isset($e)) {
1022
+			try {
1023
+				if ($this->outputExpectedRegex !== null) {
1024
+					$this->assertRegExp($this->outputExpectedRegex, $this->output);
1025
+				} elseif ($this->outputExpectedString !== null) {
1026
+					$this->assertEquals($this->outputExpectedString, $this->output);
1027
+				}
1028
+			} catch (Throwable $_e) {
1029
+				$e = $_e;
1030
+			}
1031
+		}
1032
+
1033
+		// Workaround for missing "finally".
1034
+		if (isset($e)) {
1035
+			if ($e instanceof PredictionException) {
1036
+				$e = new AssertionFailedError($e->getMessage());
1037
+			}
1038
+
1039
+			$this->onNotSuccessfulTest($e);
1040
+		}
1041
+	}
1042
+
1043
+	/**
1044
+	 * Override to run the test and assert its state.
1045
+	 *
1046
+	 * @return mixed
1047
+	 *
1048
+	 * @throws Exception|Exception
1049
+	 * @throws Exception
1050
+	 */
1051
+	protected function runTest()
1052
+	{
1053
+		if ($this->name === null) {
1054
+			throw new Exception(
1055
+				'PHPUnit\Framework\TestCase::$name must not be null.'
1056
+			);
1057
+		}
1058
+
1059
+		try {
1060
+			$class  = new ReflectionClass($this);
1061
+			$method = $class->getMethod($this->name);
1062
+		} catch (ReflectionException $e) {
1063
+			$this->fail($e->getMessage());
1064
+		}
1065
+
1066
+		$testArguments = \array_merge($this->data, $this->dependencyInput);
1067
+
1068
+		$this->registerMockObjectsFromTestArguments($testArguments);
1069
+
1070
+		try {
1071
+			$testResult = $method->invokeArgs($this, $testArguments);
1072
+		} catch (Throwable $t) {
1073
+			$exception = $t;
1074
+		}
1075
+
1076
+		if (isset($exception)) {
1077
+			if ($this->checkExceptionExpectations($exception)) {
1078
+				if ($this->expectedException !== null) {
1079
+					$this->assertThat(
1080
+						$exception,
1081
+						new ExceptionConstraint(
1082
+							$this->expectedException
1083
+						)
1084
+					);
1085
+				}
1086
+
1087
+				if ($this->expectedExceptionMessage !== null) {
1088
+					$this->assertThat(
1089
+						$exception,
1090
+						new ExceptionMessage(
1091
+							$this->expectedExceptionMessage
1092
+						)
1093
+					);
1094
+				}
1095
+
1096
+				if ($this->expectedExceptionMessageRegExp !== null) {
1097
+					$this->assertThat(
1098
+						$exception,
1099
+						new ExceptionMessageRegularExpression(
1100
+							$this->expectedExceptionMessageRegExp
1101
+						)
1102
+					);
1103
+				}
1104
+
1105
+				if ($this->expectedExceptionCode !== null) {
1106
+					$this->assertThat(
1107
+						$exception,
1108
+						new ExceptionCode(
1109
+							$this->expectedExceptionCode
1110
+						)
1111
+					);
1112
+				}
1113
+
1114
+				return;
1115
+			}
1116
+
1117
+			throw $exception;
1118
+		}
1119
+
1120
+		if ($this->expectedException !== null) {
1121
+			$this->assertThat(
1122
+				null,
1123
+				new ExceptionConstraint(
1124
+					$this->expectedException
1125
+				)
1126
+			);
1127
+		} elseif ($this->expectedExceptionMessage !== null) {
1128
+			$this->numAssertions++;
1129
+
1130
+			throw new AssertionFailedError(
1131
+				\sprintf(
1132
+					'Failed asserting that exception with message "%s" is thrown',
1133
+					$this->expectedExceptionMessage
1134
+				)
1135
+			);
1136
+		} elseif ($this->expectedExceptionMessageRegExp !== null) {
1137
+			$this->numAssertions++;
1138
+
1139
+			throw new AssertionFailedError(
1140
+				\sprintf(
1141
+					'Failed asserting that exception with message matching "%s" is thrown',
1142
+					$this->expectedExceptionMessageRegExp
1143
+				)
1144
+			);
1145
+		} elseif ($this->expectedExceptionCode !== null) {
1146
+			$this->numAssertions++;
1147
+
1148
+			throw new AssertionFailedError(
1149
+				\sprintf(
1150
+					'Failed asserting that exception with code "%s" is thrown',
1151
+					$this->expectedExceptionCode
1152
+				)
1153
+			);
1154
+		}
1155
+
1156
+		return $testResult;
1157
+	}
1158
+
1159
+	/**
1160
+	 * Verifies the mock object expectations.
1161
+	 */
1162
+	protected function verifyMockObjects()
1163
+	{
1164
+		foreach ($this->mockObjects as $mockObject) {
1165
+			if ($mockObject->__phpunit_hasMatchers()) {
1166
+				$this->numAssertions++;
1167
+			}
1168
+
1169
+			$mockObject->__phpunit_verify(
1170
+				$this->shouldInvocationMockerBeReset($mockObject)
1171
+			);
1172
+		}
1173
+
1174
+		if ($this->prophet !== null) {
1175
+			try {
1176
+				$this->prophet->checkPredictions();
1177
+			} catch (Throwable $t) {
1178
+				/* Intentionally left empty */
1179
+			}
1180
+
1181
+			foreach ($this->prophet->getProphecies() as $objectProphecy) {
1182
+				foreach ($objectProphecy->getMethodProphecies() as $methodProphecies) {
1183
+					foreach ($methodProphecies as $methodProphecy) {
1184
+						$this->numAssertions += \count($methodProphecy->getCheckedPredictions());
1185
+					}
1186
+				}
1187
+			}
1188
+
1189
+			if (isset($t)) {
1190
+				throw $t;
1191
+			}
1192
+		}
1193
+	}
1194
+
1195
+	/**
1196
+	 * Sets the name of a TestCase.
1197
+	 *
1198
+	 * @param  string
1199
+	 */
1200
+	public function setName($name)
1201
+	{
1202
+		$this->name = $name;
1203
+	}
1204
+
1205
+	/**
1206
+	 * Sets the dependencies of a TestCase.
1207
+	 *
1208
+	 * @param string[] $dependencies
1209
+	 */
1210
+	public function setDependencies(array $dependencies)
1211
+	{
1212
+		$this->dependencies = $dependencies;
1213
+	}
1214
+
1215
+	/**
1216
+	 * Returns true if the tests has dependencies
1217
+	 *
1218
+	 * @return bool
1219
+	 */
1220
+	public function hasDependencies()
1221
+	{
1222
+		return \count($this->dependencies) > 0;
1223
+	}
1224
+
1225
+	/**
1226
+	 * Sets
1227
+	 *
1228
+	 * @param array $dependencyInput
1229
+	 */
1230
+	public function setDependencyInput(array $dependencyInput)
1231
+	{
1232
+		$this->dependencyInput = $dependencyInput;
1233
+	}
1234
+
1235
+	/**
1236
+	 * @param bool $beStrictAboutChangesToGlobalState
1237
+	 */
1238
+	public function setBeStrictAboutChangesToGlobalState($beStrictAboutChangesToGlobalState)
1239
+	{
1240
+		$this->beStrictAboutChangesToGlobalState = $beStrictAboutChangesToGlobalState;
1241
+	}
1242
+
1243
+	/**
1244
+	 * Calling this method in setUp() has no effect!
1245
+	 *
1246
+	 * @param bool $backupGlobals
1247
+	 */
1248
+	public function setBackupGlobals($backupGlobals)
1249
+	{
1250
+		if (null === $this->backupGlobals && \is_bool($backupGlobals)) {
1251
+			$this->backupGlobals = $backupGlobals;
1252
+		}
1253
+	}
1254
+
1255
+	/**
1256
+	 * Calling this method in setUp() has no effect!
1257
+	 *
1258
+	 * @param bool $backupStaticAttributes
1259
+	 */
1260
+	public function setBackupStaticAttributes($backupStaticAttributes)
1261
+	{
1262
+		if (null === $this->backupStaticAttributes &&
1263
+			\is_bool($backupStaticAttributes)) {
1264
+			$this->backupStaticAttributes = $backupStaticAttributes;
1265
+		}
1266
+	}
1267
+
1268
+	/**
1269
+	 * @param bool $runTestInSeparateProcess
1270
+	 *
1271
+	 * @throws Exception
1272
+	 */
1273
+	public function setRunTestInSeparateProcess($runTestInSeparateProcess)
1274
+	{
1275
+		if (\is_bool($runTestInSeparateProcess)) {
1276
+			if ($this->runTestInSeparateProcess === null) {
1277
+				$this->runTestInSeparateProcess = $runTestInSeparateProcess;
1278
+			}
1279
+		} else {
1280
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1281
+		}
1282
+	}
1283
+
1284
+	/**
1285
+	 * @param bool $runClassInSeparateProcess
1286
+	 *
1287
+	 * @throws Exception
1288
+	 */
1289
+	public function setRunClassInSeparateProcess($runClassInSeparateProcess)
1290
+	{
1291
+		if (\is_bool($runClassInSeparateProcess)) {
1292
+			if ($this->runClassInSeparateProcess === null) {
1293
+				$this->runClassInSeparateProcess = $runClassInSeparateProcess;
1294
+			}
1295
+		} else {
1296
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1297
+		}
1298
+	}
1299
+
1300
+	/**
1301
+	 * @param bool $preserveGlobalState
1302
+	 *
1303
+	 * @throws Exception
1304
+	 */
1305
+	public function setPreserveGlobalState($preserveGlobalState)
1306
+	{
1307
+		if (\is_bool($preserveGlobalState)) {
1308
+			$this->preserveGlobalState = $preserveGlobalState;
1309
+		} else {
1310
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1311
+		}
1312
+	}
1313
+
1314
+	/**
1315
+	 * @param bool $inIsolation
1316
+	 *
1317
+	 * @throws Exception
1318
+	 */
1319
+	public function setInIsolation($inIsolation)
1320
+	{
1321
+		if (\is_bool($inIsolation)) {
1322
+			$this->inIsolation = $inIsolation;
1323
+		} else {
1324
+			throw InvalidArgumentHelper::factory(1, 'boolean');
1325
+		}
1326
+	}
1327
+
1328
+	/**
1329
+	 * @return bool
1330
+	 */
1331
+	public function isInIsolation()
1332
+	{
1333
+		return $this->inIsolation;
1334
+	}
1335
+
1336
+	/**
1337
+	 * @return mixed
1338
+	 */
1339
+	public function getResult()
1340
+	{
1341
+		return $this->testResult;
1342
+	}
1343
+
1344
+	/**
1345
+	 * @param mixed $result
1346
+	 */
1347
+	public function setResult($result)
1348
+	{
1349
+		$this->testResult = $result;
1350
+	}
1351
+
1352
+	/**
1353
+	 * @param callable $callback
1354
+	 *
1355
+	 * @throws Exception
1356
+	 */
1357
+	public function setOutputCallback($callback)
1358
+	{
1359
+		if (!\is_callable($callback)) {
1360
+			throw InvalidArgumentHelper::factory(1, 'callback');
1361
+		}
1362
+
1363
+		$this->outputCallback = $callback;
1364
+	}
1365
+
1366
+	/**
1367
+	 * @return TestResult
1368
+	 */
1369
+	public function getTestResultObject()
1370
+	{
1371
+		return $this->result;
1372
+	}
1373
+
1374
+	/**
1375
+	 * @param TestResult $result
1376
+	 */
1377
+	public function setTestResultObject(TestResult $result)
1378
+	{
1379
+		$this->result = $result;
1380
+	}
1381
+
1382
+	/**
1383
+	 * @param PHPUnit_Framework_MockObject_MockObject $mockObject
1384
+	 */
1385
+	public function registerMockObject(PHPUnit_Framework_MockObject_MockObject $mockObject)
1386
+	{
1387
+		$this->mockObjects[] = $mockObject;
1388
+	}
1389
+
1390
+	/**
1391
+	 * This method is a wrapper for the ini_set() function that automatically
1392
+	 * resets the modified php.ini setting to its original value after the
1393
+	 * test is run.
1394
+	 *
1395
+	 * @param string $varName
1396
+	 * @param string $newValue
1397
+	 *
1398
+	 * @throws Exception
1399
+	 */
1400
+	protected function iniSet($varName, $newValue)
1401
+	{
1402
+		if (!\is_string($varName)) {
1403
+			throw InvalidArgumentHelper::factory(1, 'string');
1404
+		}
1405
+
1406
+		$currentValue = \ini_set($varName, $newValue);
1407
+
1408
+		if ($currentValue !== false) {
1409
+			$this->iniSettings[$varName] = $currentValue;
1410
+		} else {
1411
+			throw new Exception(
1412
+				\sprintf(
1413
+					'INI setting "%s" could not be set to "%s".',
1414
+					$varName,
1415
+					$newValue
1416
+				)
1417
+			);
1418
+		}
1419
+	}
1420
+
1421
+	/**
1422
+	 * This method is a wrapper for the setlocale() function that automatically
1423
+	 * resets the locale to its original value after the test is run.
1424
+	 *
1425
+	 * @param int    $category
1426
+	 * @param string $locale
1427
+	 *
1428
+	 * @throws Exception
1429
+	 */
1430
+	protected function setLocale()
1431
+	{
1432
+		$args = \func_get_args();
1433
+
1434
+		if (\count($args) < 2) {
1435
+			throw new Exception;
1436
+		}
1437
+
1438
+		list($category, $locale) = $args;
1439
+
1440
+		$categories = [
1441
+			LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME
1442
+		];
1443
+
1444
+		if (\defined('LC_MESSAGES')) {
1445
+			$categories[] = LC_MESSAGES;
1446
+		}
1447
+
1448
+		if (!\in_array($category, $categories)) {
1449
+			throw new Exception;
1450
+		}
1451
+
1452
+		if (!\is_array($locale) && !\is_string($locale)) {
1453
+			throw new Exception;
1454
+		}
1455
+
1456
+		$this->locale[$category] = \setlocale($category, 0);
1457
+
1458
+		$result = \call_user_func_array('setlocale', $args);
1459
+
1460
+		if ($result === false) {
1461
+			throw new Exception(
1462
+				'The locale functionality is not implemented on your platform, ' .
1463
+				'the specified locale does not exist or the category name is ' .
1464
+				'invalid.'
1465
+			);
1466
+		}
1467
+	}
1468
+
1469
+	/**
1470
+	 * Returns a builder object to create mock objects using a fluent interface.
1471
+	 *
1472
+	 * @param string|string[] $className
1473
+	 *
1474
+	 * @return PHPUnit_Framework_MockObject_MockBuilder
1475
+	 */
1476
+	public function getMockBuilder($className)
1477
+	{
1478
+		return new PHPUnit_Framework_MockObject_MockBuilder($this, $className);
1479
+	}
1480
+
1481
+	/**
1482
+	 * Returns a test double for the specified class.
1483
+	 *
1484
+	 * @param string $originalClassName
1485
+	 *
1486
+	 * @return PHPUnit_Framework_MockObject_MockObject
1487
+	 *
1488
+	 * @throws Exception
1489
+	 */
1490
+	protected function createMock($originalClassName)
1491
+	{
1492
+		return $this->getMockBuilder($originalClassName)
1493
+			->disableOriginalConstructor()
1494
+			->disableOriginalClone()
1495
+			->disableArgumentCloning()
1496
+			->disallowMockingUnknownTypes()
1497
+			->getMock();
1498
+	}
1499
+
1500
+	/**
1501
+	 * Returns a configured test double for the specified class.
1502
+	 *
1503
+	 * @param string $originalClassName
1504
+	 * @param array  $configuration
1505
+	 *
1506
+	 * @return PHPUnit_Framework_MockObject_MockObject
1507
+	 *
1508
+	 * @throws Exception
1509
+	 */
1510
+	protected function createConfiguredMock($originalClassName, array $configuration)
1511
+	{
1512
+		$o = $this->createMock($originalClassName);
1513
+
1514
+		foreach ($configuration as $method => $return) {
1515
+			$o->method($method)->willReturn($return);
1516
+		}
1517
+
1518
+		return $o;
1519
+	}
1520
+
1521
+	/**
1522
+	 * Returns a partial test double for the specified class.
1523
+	 *
1524
+	 * @param string   $originalClassName
1525
+	 * @param string[] $methods
1526
+	 *
1527
+	 * @return PHPUnit_Framework_MockObject_MockObject
1528
+	 *
1529
+	 * @throws Exception
1530
+	 */
1531
+	protected function createPartialMock($originalClassName, array $methods)
1532
+	{
1533
+		return $this->getMockBuilder($originalClassName)
1534
+			->disableOriginalConstructor()
1535
+			->disableOriginalClone()
1536
+			->disableArgumentCloning()
1537
+			->disallowMockingUnknownTypes()
1538
+			->setMethods(empty($methods) ? null : $methods)
1539
+			->getMock();
1540
+	}
1541
+
1542
+	/**
1543
+	 * Returns a test proxy for the specified class.
1544
+	 *
1545
+	 * @param string $originalClassName
1546
+	 * @param array  $constructorArguments
1547
+	 *
1548
+	 * @return PHPUnit_Framework_MockObject_MockObject
1549
+	 *
1550
+	 * @throws Exception
1551
+	 */
1552
+	protected function createTestProxy($originalClassName, array $constructorArguments = [])
1553
+	{
1554
+		return $this->getMockBuilder($originalClassName)
1555
+			->setConstructorArgs($constructorArguments)
1556
+			->enableProxyingToOriginalMethods()
1557
+			->getMock();
1558
+	}
1559
+
1560
+	/**
1561
+	 * Mocks the specified class and returns the name of the mocked class.
1562
+	 *
1563
+	 * @param string $originalClassName
1564
+	 * @param array  $methods
1565
+	 * @param array  $arguments
1566
+	 * @param string $mockClassName
1567
+	 * @param bool   $callOriginalConstructor
1568
+	 * @param bool   $callOriginalClone
1569
+	 * @param bool   $callAutoload
1570
+	 * @param bool   $cloneArguments
1571
+	 *
1572
+	 * @return string
1573
+	 *
1574
+	 * @throws Exception
1575
+	 */
1576
+	protected function getMockClass($originalClassName, $methods = [], array $arguments = [], $mockClassName = '', $callOriginalConstructor = false, $callOriginalClone = true, $callAutoload = true, $cloneArguments = false)
1577
+	{
1578
+		$mock = $this->getMockObjectGenerator()->getMock(
1579
+			$originalClassName,
1580
+			$methods,
1581
+			$arguments,
1582
+			$mockClassName,
1583
+			$callOriginalConstructor,
1584
+			$callOriginalClone,
1585
+			$callAutoload,
1586
+			$cloneArguments
1587
+		);
1588
+
1589
+		return \get_class($mock);
1590
+	}
1591
+
1592
+	/**
1593
+	 * Returns a mock object for the specified abstract class with all abstract
1594
+	 * methods of the class mocked. Concrete methods are not mocked by default.
1595
+	 * To mock concrete methods, use the 7th parameter ($mockedMethods).
1596
+	 *
1597
+	 * @param string $originalClassName
1598
+	 * @param array  $arguments
1599
+	 * @param string $mockClassName
1600
+	 * @param bool   $callOriginalConstructor
1601
+	 * @param bool   $callOriginalClone
1602
+	 * @param bool   $callAutoload
1603
+	 * @param array  $mockedMethods
1604
+	 * @param bool   $cloneArguments
1605
+	 *
1606
+	 * @return PHPUnit_Framework_MockObject_MockObject
1607
+	 *
1608
+	 * @throws Exception
1609
+	 */
1610
+	protected function getMockForAbstractClass($originalClassName, array $arguments = [], $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true, $mockedMethods = [], $cloneArguments = false)
1611
+	{
1612
+		$mockObject = $this->getMockObjectGenerator()->getMockForAbstractClass(
1613
+			$originalClassName,
1614
+			$arguments,
1615
+			$mockClassName,
1616
+			$callOriginalConstructor,
1617
+			$callOriginalClone,
1618
+			$callAutoload,
1619
+			$mockedMethods,
1620
+			$cloneArguments
1621
+		);
1622
+
1623
+		$this->registerMockObject($mockObject);
1624
+
1625
+		return $mockObject;
1626
+	}
1627
+
1628
+	/**
1629
+	 * Returns a mock object based on the given WSDL file.
1630
+	 *
1631
+	 * @param string $wsdlFile
1632
+	 * @param string $originalClassName
1633
+	 * @param string $mockClassName
1634
+	 * @param array  $methods
1635
+	 * @param bool   $callOriginalConstructor
1636
+	 * @param array  $options                 An array of options passed to SOAPClient::_construct
1637
+	 *
1638
+	 * @return PHPUnit_Framework_MockObject_MockObject
1639
+	 */
1640
+	protected function getMockFromWsdl($wsdlFile, $originalClassName = '', $mockClassName = '', array $methods = [], $callOriginalConstructor = true, array $options = [])
1641
+	{
1642
+		if ($originalClassName === '') {
1643
+			$originalClassName = \pathinfo(\basename(\parse_url($wsdlFile)['path']), PATHINFO_FILENAME);
1644
+		}
1645
+
1646
+		if (!\class_exists($originalClassName)) {
1647
+			eval(
1648
+				$this->getMockObjectGenerator()->generateClassFromWsdl(
1649
+					$wsdlFile,
1650
+					$originalClassName,
1651
+					$methods,
1652
+					$options
1653
+				)
1654
+			);
1655
+		}
1656
+
1657
+		$mockObject = $this->getMockObjectGenerator()->getMock(
1658
+			$originalClassName,
1659
+			$methods,
1660
+			['', $options],
1661
+			$mockClassName,
1662
+			$callOriginalConstructor,
1663
+			false,
1664
+			false
1665
+		);
1666
+
1667
+		$this->registerMockObject($mockObject);
1668
+
1669
+		return $mockObject;
1670
+	}
1671
+
1672
+	/**
1673
+	 * Returns a mock object for the specified trait with all abstract methods
1674
+	 * of the trait mocked. Concrete methods to mock can be specified with the
1675
+	 * `$mockedMethods` parameter.
1676
+	 *
1677
+	 * @param string $traitName
1678
+	 * @param array  $arguments
1679
+	 * @param string $mockClassName
1680
+	 * @param bool   $callOriginalConstructor
1681
+	 * @param bool   $callOriginalClone
1682
+	 * @param bool   $callAutoload
1683
+	 * @param array  $mockedMethods
1684
+	 * @param bool   $cloneArguments
1685
+	 *
1686
+	 * @return PHPUnit_Framework_MockObject_MockObject
1687
+	 *
1688
+	 * @throws Exception
1689
+	 */
1690
+	protected function getMockForTrait($traitName, array $arguments = [], $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true, $mockedMethods = [], $cloneArguments = false)
1691
+	{
1692
+		$mockObject = $this->getMockObjectGenerator()->getMockForTrait(
1693
+			$traitName,
1694
+			$arguments,
1695
+			$mockClassName,
1696
+			$callOriginalConstructor,
1697
+			$callOriginalClone,
1698
+			$callAutoload,
1699
+			$mockedMethods,
1700
+			$cloneArguments
1701
+		);
1702
+
1703
+		$this->registerMockObject($mockObject);
1704
+
1705
+		return $mockObject;
1706
+	}
1707
+
1708
+	/**
1709
+	 * Returns an object for the specified trait.
1710
+	 *
1711
+	 * @param string $traitName
1712
+	 * @param array  $arguments
1713
+	 * @param string $traitClassName
1714
+	 * @param bool   $callOriginalConstructor
1715
+	 * @param bool   $callOriginalClone
1716
+	 * @param bool   $callAutoload
1717
+	 *
1718
+	 * @return object
1719
+	 *
1720
+	 * @throws Exception
1721
+	 */
1722
+	protected function getObjectForTrait($traitName, array $arguments = [], $traitClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true)
1723
+	{
1724
+		return $this->getMockObjectGenerator()->getObjectForTrait(
1725
+			$traitName,
1726
+			$arguments,
1727
+			$traitClassName,
1728
+			$callOriginalConstructor,
1729
+			$callOriginalClone,
1730
+			$callAutoload
1731
+		);
1732
+	}
1733
+
1734
+	/**
1735
+	 * @param string|null $classOrInterface
1736
+	 *
1737
+	 * @return \Prophecy\Prophecy\ObjectProphecy
1738
+	 *
1739
+	 * @throws \LogicException
1740
+	 */
1741
+	protected function prophesize($classOrInterface = null)
1742
+	{
1743
+		return $this->getProphet()->prophesize($classOrInterface);
1744
+	}
1745
+
1746
+	/**
1747
+	 * Adds a value to the assertion counter.
1748
+	 *
1749
+	 * @param int $count
1750
+	 */
1751
+	public function addToAssertionCount($count)
1752
+	{
1753
+		$this->numAssertions += $count;
1754
+	}
1755
+
1756
+	/**
1757
+	 * Returns the number of assertions performed by this test.
1758
+	 *
1759
+	 * @return int
1760
+	 */
1761
+	public function getNumAssertions()
1762
+	{
1763
+		return $this->numAssertions;
1764
+	}
1765
+
1766
+	/**
1767
+	 * Returns a matcher that matches when the method is executed
1768
+	 * zero or more times.
1769
+	 *
1770
+	 * @return PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount
1771
+	 */
1772
+	public static function any()
1773
+	{
1774
+		return new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
1775
+	}
1776
+
1777
+	/**
1778
+	 * Returns a matcher that matches when the method is never executed.
1779
+	 *
1780
+	 * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
1781
+	 */
1782
+	public static function never()
1783
+	{
1784
+		return new PHPUnit_Framework_MockObject_Matcher_InvokedCount(0);
1785
+	}
1786
+
1787
+	/**
1788
+	 * Returns a matcher that matches when the method is executed
1789
+	 * at least N times.
1790
+	 *
1791
+	 * @param int $requiredInvocations
1792
+	 *
1793
+	 * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastCount
1794
+	 */
1795
+	public static function atLeast($requiredInvocations)
1796
+	{
1797
+		return new PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastCount(
1798
+			$requiredInvocations
1799
+		);
1800
+	}
1801
+
1802
+	/**
1803
+	 * Returns a matcher that matches when the method is executed at least once.
1804
+	 *
1805
+	 * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce
1806
+	 */
1807
+	public static function atLeastOnce()
1808
+	{
1809
+		return new PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce;
1810
+	}
1811
+
1812
+	/**
1813
+	 * Returns a matcher that matches when the method is executed exactly once.
1814
+	 *
1815
+	 * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
1816
+	 */
1817
+	public static function once()
1818
+	{
1819
+		return new PHPUnit_Framework_MockObject_Matcher_InvokedCount(1);
1820
+	}
1821
+
1822
+	/**
1823
+	 * Returns a matcher that matches when the method is executed
1824
+	 * exactly $count times.
1825
+	 *
1826
+	 * @param int $count
1827
+	 *
1828
+	 * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
1829
+	 */
1830
+	public static function exactly($count)
1831
+	{
1832
+		return new PHPUnit_Framework_MockObject_Matcher_InvokedCount($count);
1833
+	}
1834
+
1835
+	/**
1836
+	 * Returns a matcher that matches when the method is executed
1837
+	 * at most N times.
1838
+	 *
1839
+	 * @param int $allowedInvocations
1840
+	 *
1841
+	 * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtMostCount
1842
+	 */
1843
+	public static function atMost($allowedInvocations)
1844
+	{
1845
+		return new PHPUnit_Framework_MockObject_Matcher_InvokedAtMostCount(
1846
+			$allowedInvocations
1847
+		);
1848
+	}
1849
+
1850
+	/**
1851
+	 * Returns a matcher that matches when the method is executed
1852
+	 * at the given index.
1853
+	 *
1854
+	 * @param int $index
1855
+	 *
1856
+	 * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex
1857
+	 */
1858
+	public static function at($index)
1859
+	{
1860
+		return new PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex($index);
1861
+	}
1862
+
1863
+	/**
1864
+	 * @param mixed $value
1865
+	 *
1866
+	 * @return PHPUnit_Framework_MockObject_Stub_Return
1867
+	 */
1868
+	public static function returnValue($value)
1869
+	{
1870
+		return new PHPUnit_Framework_MockObject_Stub_Return($value);
1871
+	}
1872
+
1873
+	/**
1874
+	 * @param array $valueMap
1875
+	 *
1876
+	 * @return PHPUnit_Framework_MockObject_Stub_ReturnValueMap
1877
+	 */
1878
+	public static function returnValueMap(array $valueMap)
1879
+	{
1880
+		return new PHPUnit_Framework_MockObject_Stub_ReturnValueMap($valueMap);
1881
+	}
1882
+
1883
+	/**
1884
+	 * @param int $argumentIndex
1885
+	 *
1886
+	 * @return PHPUnit_Framework_MockObject_Stub_ReturnArgument
1887
+	 */
1888
+	public static function returnArgument($argumentIndex)
1889
+	{
1890
+		return new PHPUnit_Framework_MockObject_Stub_ReturnArgument(
1891
+			$argumentIndex
1892
+		);
1893
+	}
1894
+
1895
+	/**
1896
+	 * @param mixed $callback
1897
+	 *
1898
+	 * @return PHPUnit_Framework_MockObject_Stub_ReturnCallback
1899
+	 */
1900
+	public static function returnCallback($callback)
1901
+	{
1902
+		return new PHPUnit_Framework_MockObject_Stub_ReturnCallback($callback);
1903
+	}
1904
+
1905
+	/**
1906
+	 * Returns the current object.
1907
+	 *
1908
+	 * This method is useful when mocking a fluent interface.
1909
+	 *
1910
+	 * @return PHPUnit_Framework_MockObject_Stub_ReturnSelf
1911
+	 */
1912
+	public static function returnSelf()
1913
+	{
1914
+		return new PHPUnit_Framework_MockObject_Stub_ReturnSelf();
1915
+	}
1916
+
1917
+	/**
1918
+	 * @param Throwable $exception
1919
+	 *
1920
+	 * @return PHPUnit_Framework_MockObject_Stub_Exception
1921
+	 */
1922
+	public static function throwException(Throwable $exception)
1923
+	{
1924
+		return new PHPUnit_Framework_MockObject_Stub_Exception($exception);
1925
+	}
1926
+
1927
+	/**
1928
+	 * @param mixed $value , ...
1929
+	 *
1930
+	 * @return PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls
1931
+	 */
1932
+	public static function onConsecutiveCalls()
1933
+	{
1934
+		$args = \func_get_args();
1935
+
1936
+		return new PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls($args);
1937
+	}
1938
+
1939
+	/**
1940
+	 * @return bool
1941
+	 */
1942
+	public function usesDataProvider()
1943
+	{
1944
+		return !empty($this->data);
1945
+	}
1946
+
1947
+	/**
1948
+	 * @return string
1949
+	 */
1950
+	public function dataDescription()
1951
+	{
1952
+		return \is_string($this->dataName) ? $this->dataName : '';
1953
+	}
1954
+
1955
+	public function registerComparator(Comparator $comparator)
1956
+	{
1957
+		ComparatorFactory::getInstance()->register($comparator);
1958
+
1959
+		$this->customComparators[] = $comparator;
1960
+	}
1961
+
1962
+	/**
1963
+	 * Gets the data set description of a TestCase.
1964
+	 *
1965
+	 * @param bool $includeData
1966
+	 *
1967
+	 * @return string
1968
+	 */
1969
+	public function getDataSetAsString($includeData = true)
1970
+	{
1971
+		$buffer = '';
1972
+
1973
+		if (!empty($this->data)) {
1974
+			if (\is_int($this->dataName)) {
1975
+				$buffer .= \sprintf(' with data set #%d', $this->dataName);
1976
+			} else {
1977
+				$buffer .= \sprintf(' with data set "%s"', $this->dataName);
1978
+			}
1979
+
1980
+			$exporter = new Exporter;
1981
+
1982
+			if ($includeData) {
1983
+				$buffer .= \sprintf(' (%s)', $exporter->shortenedRecursiveExport($this->data));
1984
+			}
1985
+		}
1986
+
1987
+		return $buffer;
1988
+	}
1989
+
1990
+	/**
1991
+	 * Gets the data set of a TestCase.
1992
+	 *
1993
+	 * @return array
1994
+	 */
1995
+	protected function getProvidedData()
1996
+	{
1997
+		return $this->data;
1998
+	}
1999
+
2000
+	/**
2001
+	 * Creates a default TestResult object.
2002
+	 *
2003
+	 * @return TestResult
2004
+	 */
2005
+	protected function createResult()
2006
+	{
2007
+		return new TestResult;
2008
+	}
2009
+
2010
+	protected function handleDependencies()
2011
+	{
2012
+		if (!empty($this->dependencies) && !$this->inIsolation) {
2013
+			$className  = \get_class($this);
2014
+			$passed     = $this->result->passed();
2015
+			$passedKeys = \array_keys($passed);
2016
+			$numKeys    = \count($passedKeys);
2017
+
2018
+			for ($i = 0; $i < $numKeys; $i++) {
2019
+				$pos = \strpos($passedKeys[$i], ' with data set');
2020
+
2021
+				if ($pos !== false) {
2022
+					$passedKeys[$i] = \substr($passedKeys[$i], 0, $pos);
2023
+				}
2024
+			}
2025
+
2026
+			$passedKeys = \array_flip(\array_unique($passedKeys));
2027
+
2028
+			foreach ($this->dependencies as $dependency) {
2029
+				$clone = false;
2030
+
2031
+				if (\strpos($dependency, 'clone ') === 0) {
2032
+					$clone      = true;
2033
+					$dependency = \substr($dependency, \strlen('clone '));
2034
+				} elseif (\strpos($dependency, '!clone ') === 0) {
2035
+					$clone      = false;
2036
+					$dependency = \substr($dependency, \strlen('!clone '));
2037
+				}
2038
+
2039
+				if (\strpos($dependency, '::') === false) {
2040
+					$dependency = $className . '::' . $dependency;
2041
+				}
2042
+
2043
+				if (!isset($passedKeys[$dependency])) {
2044
+					$this->result->startTest($this);
2045
+					$this->result->addError(
2046
+						$this,
2047
+						new SkippedTestError(
2048
+							\sprintf(
2049
+								'This test depends on "%s" to pass.',
2050
+								$dependency
2051
+							)
2052
+						),
2053
+						0
2054
+					);
2055
+					$this->result->endTest($this, 0);
2056
+
2057
+					return false;
2058
+				}
2059
+
2060
+				if (isset($passed[$dependency])) {
2061
+					if ($passed[$dependency]['size'] != \PHPUnit\Util\Test::UNKNOWN &&
2062
+						$this->getSize() != \PHPUnit\Util\Test::UNKNOWN &&
2063
+						$passed[$dependency]['size'] > $this->getSize()) {
2064
+						$this->result->addError(
2065
+							$this,
2066
+							new SkippedTestError(
2067
+								'This test depends on a test that is larger than itself.'
2068
+							),
2069
+							0
2070
+						);
2071
+
2072
+						return false;
2073
+					}
2074
+
2075
+					if ($clone) {
2076
+						$deepCopy = new DeepCopy;
2077
+						$deepCopy->skipUncloneable(false);
2078
+
2079
+						$this->dependencyInput[$dependency] = $deepCopy->copy($passed[$dependency]['result']);
2080
+					} else {
2081
+						$this->dependencyInput[$dependency] = $passed[$dependency]['result'];
2082
+					}
2083
+				} else {
2084
+					$this->dependencyInput[$dependency] = null;
2085
+				}
2086
+			}
2087
+		}
2088
+
2089
+		return true;
2090
+	}
2091
+
2092
+	/**
2093
+	 * This method is called before the first test of this test class is run.
2094
+	 */
2095
+	public static function setUpBeforeClass()
2096
+	{
2097
+	}
2098
+
2099
+	/**
2100
+	 * Sets up the fixture, for example, open a network connection.
2101
+	 * This method is called before a test is executed.
2102
+	 */
2103
+	protected function setUp()
2104
+	{
2105
+	}
2106
+
2107
+	/**
2108
+	 * Performs assertions shared by all tests of a test case.
2109
+	 *
2110
+	 * This method is called before the execution of a test starts
2111
+	 * and after setUp() is called.
2112
+	 */
2113
+	protected function assertPreConditions()
2114
+	{
2115
+	}
2116
+
2117
+	/**
2118
+	 * Performs assertions shared by all tests of a test case.
2119
+	 *
2120
+	 * This method is called after the execution of a test ends
2121
+	 * and before tearDown() is called.
2122
+	 */
2123
+	protected function assertPostConditions()
2124
+	{
2125
+	}
2126
+
2127
+	/**
2128
+	 * Tears down the fixture, for example, close a network connection.
2129
+	 * This method is called after a test is executed.
2130
+	 */
2131
+	protected function tearDown()
2132
+	{
2133
+	}
2134
+
2135
+	/**
2136
+	 * This method is called after the last test of this test class is run.
2137
+	 */
2138
+	public static function tearDownAfterClass()
2139
+	{
2140
+	}
2141
+
2142
+	/**
2143
+	 * This method is called when a test method did not execute successfully.
2144
+	 *
2145
+	 * @param Throwable $t
2146
+	 *
2147
+	 * @throws Throwable
2148
+	 */
2149
+	protected function onNotSuccessfulTest(Throwable $t)
2150
+	{
2151
+		throw $t;
2152
+	}
2153
+
2154
+	/**
2155
+	 * Performs custom preparations on the process isolation template.
2156
+	 *
2157
+	 * @param Text_Template $template
2158
+	 */
2159
+	protected function prepareTemplate(Text_Template $template)
2160
+	{
2161
+	}
2162
+
2163
+	/**
2164
+	 * Get the mock object generator, creating it if it doesn't exist.
2165
+	 *
2166
+	 * @return PHPUnit_Framework_MockObject_Generator
2167
+	 */
2168
+	private function getMockObjectGenerator()
2169
+	{
2170
+		if (null === $this->mockObjectGenerator) {
2171
+			$this->mockObjectGenerator = new PHPUnit_Framework_MockObject_Generator;
2172
+		}
2173
+
2174
+		return $this->mockObjectGenerator;
2175
+	}
2176
+
2177
+	private function startOutputBuffering()
2178
+	{
2179
+		\ob_start();
2180
+
2181
+		$this->outputBufferingActive = true;
2182
+		$this->outputBufferingLevel  = \ob_get_level();
2183
+	}
2184
+
2185
+	private function stopOutputBuffering()
2186
+	{
2187
+		if (\ob_get_level() != $this->outputBufferingLevel) {
2188
+			while (\ob_get_level() >= $this->outputBufferingLevel) {
2189
+				\ob_end_clean();
2190
+			}
2191
+
2192
+			throw new RiskyTestError(
2193
+				'Test code or tested code did not (only) close its own output buffers'
2194
+			);
2195
+		}
2196
+
2197
+		$output = \ob_get_contents();
2198
+
2199
+		if ($this->outputCallback === false) {
2200
+			$this->output = $output;
2201
+		} else {
2202
+			$this->output = \call_user_func_array(
2203
+				$this->outputCallback,
2204
+				[$output]
2205
+			);
2206
+		}
2207
+
2208
+		\ob_end_clean();
2209
+
2210
+		$this->outputBufferingActive = false;
2211
+		$this->outputBufferingLevel  = \ob_get_level();
2212
+	}
2213
+
2214
+	private function snapshotGlobalState()
2215
+	{
2216
+		if ($this->runTestInSeparateProcess ||
2217
+			$this->inIsolation ||
2218
+			(!$this->backupGlobals === true && !$this->backupStaticAttributes)) {
2219
+			return;
2220
+		}
2221
+
2222
+		$this->snapshot = $this->createGlobalStateSnapshot($this->backupGlobals === true);
2223
+	}
2224
+
2225
+	private function restoreGlobalState()
2226
+	{
2227
+		if (!$this->snapshot instanceof Snapshot) {
2228
+			return;
2229
+		}
2230
+
2231
+		if ($this->beStrictAboutChangesToGlobalState) {
2232
+			try {
2233
+				$this->compareGlobalStateSnapshots(
2234
+					$this->snapshot,
2235
+					$this->createGlobalStateSnapshot($this->backupGlobals === true)
2236
+				);
2237
+			} catch (RiskyTestError $rte) {
2238
+				// Intentionally left empty
2239
+			}
2240
+		}
2241
+
2242
+		$restorer = new Restorer;
2243
+
2244
+		if ($this->backupGlobals === true) {
2245
+			$restorer->restoreGlobalVariables($this->snapshot);
2246
+		}
2247
+
2248
+		if ($this->backupStaticAttributes) {
2249
+			$restorer->restoreStaticAttributes($this->snapshot);
2250
+		}
2251
+
2252
+		$this->snapshot = null;
2253
+
2254
+		if (isset($rte)) {
2255
+			throw $rte;
2256
+		}
2257
+	}
2258
+
2259
+	/**
2260
+	 * @param bool $backupGlobals
2261
+	 *
2262
+	 * @return Snapshot
2263
+	 */
2264
+	private function createGlobalStateSnapshot($backupGlobals)
2265
+	{
2266
+		$blacklist = new Blacklist;
2267
+
2268
+		foreach ($this->backupGlobalsBlacklist as $globalVariable) {
2269
+			$blacklist->addGlobalVariable($globalVariable);
2270
+		}
2271
+
2272
+		if (!\defined('PHPUNIT_TESTSUITE')) {
2273
+			$blacklist->addClassNamePrefix('PHPUnit');
2274
+			$blacklist->addClassNamePrefix('File_Iterator');
2275
+			$blacklist->addClassNamePrefix('SebastianBergmann\CodeCoverage');
2276
+			$blacklist->addClassNamePrefix('PHP_Invoker');
2277
+			$blacklist->addClassNamePrefix('PHP_Timer');
2278
+			$blacklist->addClassNamePrefix('PHP_Token');
2279
+			$blacklist->addClassNamePrefix('Symfony');
2280
+			$blacklist->addClassNamePrefix('Text_Template');
2281
+			$blacklist->addClassNamePrefix('Doctrine\Instantiator');
2282
+			$blacklist->addClassNamePrefix('Prophecy');
2283
+
2284
+			foreach ($this->backupStaticAttributesBlacklist as $class => $attributes) {
2285
+				foreach ($attributes as $attribute) {
2286
+					$blacklist->addStaticAttribute($class, $attribute);
2287
+				}
2288
+			}
2289
+		}
2290
+
2291
+		return new Snapshot(
2292
+			$blacklist,
2293
+			$backupGlobals,
2294
+			(bool) $this->backupStaticAttributes,
2295
+			false,
2296
+			false,
2297
+			false,
2298
+			false,
2299
+			false,
2300
+			false,
2301
+			false
2302
+		);
2303
+	}
2304
+
2305
+	/**
2306
+	 * @param Snapshot $before
2307
+	 * @param Snapshot $after
2308
+	 *
2309
+	 * @throws RiskyTestError
2310
+	 */
2311
+	private function compareGlobalStateSnapshots(Snapshot $before, Snapshot $after)
2312
+	{
2313
+		$backupGlobals = $this->backupGlobals === null || $this->backupGlobals === true;
2314
+
2315
+		if ($backupGlobals) {
2316
+			$this->compareGlobalStateSnapshotPart(
2317
+				$before->globalVariables(),
2318
+				$after->globalVariables(),
2319
+				"--- Global variables before the test\n+++ Global variables after the test\n"
2320
+			);
2321
+
2322
+			$this->compareGlobalStateSnapshotPart(
2323
+				$before->superGlobalVariables(),
2324
+				$after->superGlobalVariables(),
2325
+				"--- Super-global variables before the test\n+++ Super-global variables after the test\n"
2326
+			);
2327
+		}
2328
+
2329
+		if ($this->backupStaticAttributes) {
2330
+			$this->compareGlobalStateSnapshotPart(
2331
+				$before->staticAttributes(),
2332
+				$after->staticAttributes(),
2333
+				"--- Static attributes before the test\n+++ Static attributes after the test\n"
2334
+			);
2335
+		}
2336
+	}
2337
+
2338
+	/**
2339
+	 * @param array  $before
2340
+	 * @param array  $after
2341
+	 * @param string $header
2342
+	 *
2343
+	 * @throws RiskyTestError
2344
+	 */
2345
+	private function compareGlobalStateSnapshotPart(array $before, array $after, $header)
2346
+	{
2347
+		if ($before != $after) {
2348
+			$differ   = new Differ($header);
2349
+			$exporter = new Exporter;
2350
+
2351
+			$diff = $differ->diff(
2352
+				$exporter->export($before),
2353
+				$exporter->export($after)
2354
+			);
2355
+
2356
+			throw new RiskyTestError(
2357
+				$diff
2358
+			);
2359
+		}
2360
+	}
2361
+
2362
+	/**
2363
+	 * @return Prophecy\Prophet
2364
+	 */
2365
+	private function getProphet()
2366
+	{
2367
+		if ($this->prophet === null) {
2368
+			$this->prophet = new Prophet;
2369
+		}
2370
+
2371
+		return $this->prophet;
2372
+	}
2373
+
2374
+	/**
2375
+	 * @param PHPUnit_Framework_MockObject_MockObject $mock
2376
+	 *
2377
+	 * @return bool
2378
+	 */
2379
+	private function shouldInvocationMockerBeReset(PHPUnit_Framework_MockObject_MockObject $mock)
2380
+	{
2381
+		$enumerator = new Enumerator;
2382
+
2383
+		foreach ($enumerator->enumerate($this->dependencyInput) as $object) {
2384
+			if ($mock === $object) {
2385
+				return false;
2386
+			}
2387
+		}
2388
+
2389
+		if (!\is_array($this->testResult) && !\is_object($this->testResult)) {
2390
+			return true;
2391
+		}
2392
+
2393
+		foreach ($enumerator->enumerate($this->testResult) as $object) {
2394
+			if ($mock === $object) {
2395
+				return false;
2396
+			}
2397
+		}
2398
+
2399
+		return true;
2400
+	}
2401
+
2402
+	/**
2403
+	 * @param array $testArguments
2404
+	 * @param array $visited
2405
+	 */
2406
+	private function registerMockObjectsFromTestArguments(array $testArguments, array &$visited = [])
2407
+	{
2408
+		if ($this->registerMockObjectsFromTestArgumentsRecursively) {
2409
+			$enumerator = new Enumerator;
2410
+
2411
+			foreach ($enumerator->enumerate($testArguments) as $object) {
2412
+				if ($object instanceof PHPUnit_Framework_MockObject_MockObject) {
2413
+					$this->registerMockObject($object);
2414
+				}
2415
+			}
2416
+		} else {
2417
+			foreach ($testArguments as $testArgument) {
2418
+				if ($testArgument instanceof PHPUnit_Framework_MockObject_MockObject) {
2419
+					if ($this->isCloneable($testArgument)) {
2420
+						$testArgument = clone $testArgument;
2421
+					}
2422
+
2423
+					$this->registerMockObject($testArgument);
2424
+				} elseif (\is_array($testArgument) && !\in_array($testArgument, $visited, true)) {
2425
+					$visited[] = $testArgument;
2426
+
2427
+					$this->registerMockObjectsFromTestArguments(
2428
+						$testArgument,
2429
+						$visited
2430
+					);
2431
+				}
2432
+			}
2433
+		}
2434
+	}
2435
+
2436
+	private function setDoesNotPerformAssertionsFromAnnotation()
2437
+	{
2438
+		$annotations = $this->getAnnotations();
2439
+
2440
+		if (isset($annotations['method']['doesNotPerformAssertions'])) {
2441
+			$this->doesNotPerformAssertions = true;
2442
+		}
2443
+	}
2444
+
2445
+	/**
2446
+	 * @param PHPUnit_Framework_MockObject_MockObject $testArgument
2447
+	 *
2448
+	 * @return bool
2449
+	 */
2450
+	private function isCloneable(PHPUnit_Framework_MockObject_MockObject $testArgument)
2451
+	{
2452
+		$reflector = new ReflectionObject($testArgument);
2453
+
2454
+		if (!$reflector->isCloneable()) {
2455
+			return false;
2456
+		}
2457
+
2458
+		if ($reflector->hasMethod('__clone') &&
2459
+			$reflector->getMethod('__clone')->isPublic()) {
2460
+			return true;
2461
+		}
2462
+
2463
+		return false;
2464
+	}
2465
+
2466
+	private function unregisterCustomComparators()
2467
+	{
2468
+		$factory = ComparatorFactory::getInstance();
2469
+
2470
+		foreach ($this->customComparators as $comparator) {
2471
+			$factory->unregister($comparator);
2472
+		}
2473
+
2474
+		$this->customComparators = [];
2475
+	}
2476
+
2477
+	private function cleanupIniSettings()
2478
+	{
2479
+		foreach ($this->iniSettings as $varName => $oldValue) {
2480
+			\ini_set($varName, $oldValue);
2481
+		}
2482
+
2483
+		$this->iniSettings = [];
2484
+	}
2485
+
2486
+	private function cleanupLocaleSettings()
2487
+	{
2488
+		foreach ($this->locale as $category => $locale) {
2489
+			\setlocale($category, $locale);
2490
+		}
2491
+
2492
+		$this->locale = [];
2493
+	}
2494
+
2495
+	private function checkExceptionExpectations(Throwable $throwable): bool
2496
+	{
2497
+		$result = false;
2498
+
2499
+		if ($this->expectedException !== null || $this->expectedExceptionCode !== null || $this->expectedExceptionMessage !== null || $this->expectedExceptionMessageRegExp !== null) {
2500
+			$result = true;
2501
+		}
2502
+
2503
+		if ($throwable instanceof Exception) {
2504
+			$result = false;
2505
+		}
2506
+
2507
+		if (\is_string($this->expectedException)) {
2508
+			$reflector = new ReflectionClass($this->expectedException);
2509
+
2510
+			if ($this->expectedException === 'PHPUnit\Framework\Exception' ||
2511
+				$this->expectedException === '\PHPUnit\Framework\Exception' ||
2512
+				$reflector->isSubclassOf('PHPUnit\Framework\Exception')) {
2513
+				$result = true;
2514
+			}
2515
+		}
2516
+
2517
+		return $result;
2518
+	}
2519 2519
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/TestSuiteIterator.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -16,89 +16,89 @@
 block discarded – undo
16 16
  */
17 17
 class TestSuiteIterator implements RecursiveIterator
18 18
 {
19
-    /**
20
-     * @var int
21
-     */
22
-    protected $position;
19
+	/**
20
+	 * @var int
21
+	 */
22
+	protected $position;
23 23
 
24
-    /**
25
-     * @var Test[]
26
-     */
27
-    protected $tests;
24
+	/**
25
+	 * @var Test[]
26
+	 */
27
+	protected $tests;
28 28
 
29
-    /**
30
-     * @param TestSuite $testSuite
31
-     */
32
-    public function __construct(TestSuite $testSuite)
33
-    {
34
-        $this->tests = $testSuite->tests();
35
-    }
29
+	/**
30
+	 * @param TestSuite $testSuite
31
+	 */
32
+	public function __construct(TestSuite $testSuite)
33
+	{
34
+		$this->tests = $testSuite->tests();
35
+	}
36 36
 
37
-    /**
38
-     * Rewinds the Iterator to the first element.
39
-     */
40
-    public function rewind()
41
-    {
42
-        $this->position = 0;
43
-    }
37
+	/**
38
+	 * Rewinds the Iterator to the first element.
39
+	 */
40
+	public function rewind()
41
+	{
42
+		$this->position = 0;
43
+	}
44 44
 
45
-    /**
46
-     * Checks if there is a current element after calls to rewind() or next().
47
-     *
48
-     * @return bool
49
-     */
50
-    public function valid()
51
-    {
52
-        return $this->position < \count($this->tests);
53
-    }
45
+	/**
46
+	 * Checks if there is a current element after calls to rewind() or next().
47
+	 *
48
+	 * @return bool
49
+	 */
50
+	public function valid()
51
+	{
52
+		return $this->position < \count($this->tests);
53
+	}
54 54
 
55
-    /**
56
-     * Returns the key of the current element.
57
-     *
58
-     * @return int
59
-     */
60
-    public function key()
61
-    {
62
-        return $this->position;
63
-    }
55
+	/**
56
+	 * Returns the key of the current element.
57
+	 *
58
+	 * @return int
59
+	 */
60
+	public function key()
61
+	{
62
+		return $this->position;
63
+	}
64 64
 
65
-    /**
66
-     * Returns the current element.
67
-     *
68
-     * @return Test
69
-     */
70
-    public function current()
71
-    {
72
-        return $this->valid() ? $this->tests[$this->position] : null;
73
-    }
65
+	/**
66
+	 * Returns the current element.
67
+	 *
68
+	 * @return Test
69
+	 */
70
+	public function current()
71
+	{
72
+		return $this->valid() ? $this->tests[$this->position] : null;
73
+	}
74 74
 
75
-    /**
76
-     * Moves forward to next element.
77
-     */
78
-    public function next()
79
-    {
80
-        $this->position++;
81
-    }
75
+	/**
76
+	 * Moves forward to next element.
77
+	 */
78
+	public function next()
79
+	{
80
+		$this->position++;
81
+	}
82 82
 
83
-    /**
84
-     * Returns the sub iterator for the current element.
85
-     *
86
-     * @return TestSuiteIterator
87
-     */
88
-    public function getChildren()
89
-    {
90
-        return new self(
91
-            $this->tests[$this->position]
92
-        );
93
-    }
83
+	/**
84
+	 * Returns the sub iterator for the current element.
85
+	 *
86
+	 * @return TestSuiteIterator
87
+	 */
88
+	public function getChildren()
89
+	{
90
+		return new self(
91
+			$this->tests[$this->position]
92
+		);
93
+	}
94 94
 
95
-    /**
96
-     * Checks whether the current element has children.
97
-     *
98
-     * @return bool
99
-     */
100
-    public function hasChildren()
101
-    {
102
-        return $this->tests[$this->position] instanceof TestSuite;
103
-    }
95
+	/**
96
+	 * Checks whether the current element has children.
97
+	 *
98
+	 * @return bool
99
+	 */
100
+	public function hasChildren()
101
+	{
102
+		return $this->tests[$this->position] instanceof TestSuite;
103
+	}
104 104
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/TestListenerDefaultImplementation.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -11,43 +11,43 @@
 block discarded – undo
11 11
 
12 12
 trait TestListenerDefaultImplementation
13 13
 {
14
-    public function addError(Test $test, \Exception $e, $time)
15
-    {
16
-    }
14
+	public function addError(Test $test, \Exception $e, $time)
15
+	{
16
+	}
17 17
 
18
-    public function addWarning(Test $test, Warning $e, $time)
19
-    {
20
-    }
18
+	public function addWarning(Test $test, Warning $e, $time)
19
+	{
20
+	}
21 21
 
22
-    public function addFailure(Test $test, AssertionFailedError $e, $time)
23
-    {
24
-    }
22
+	public function addFailure(Test $test, AssertionFailedError $e, $time)
23
+	{
24
+	}
25 25
 
26
-    public function addIncompleteTest(Test $test, \Exception $e, $time)
27
-    {
28
-    }
26
+	public function addIncompleteTest(Test $test, \Exception $e, $time)
27
+	{
28
+	}
29 29
 
30
-    public function addRiskyTest(Test $test, \Exception $e, $time)
31
-    {
32
-    }
30
+	public function addRiskyTest(Test $test, \Exception $e, $time)
31
+	{
32
+	}
33 33
 
34
-    public function addSkippedTest(Test $test, \Exception $e, $time)
35
-    {
36
-    }
34
+	public function addSkippedTest(Test $test, \Exception $e, $time)
35
+	{
36
+	}
37 37
 
38
-    public function startTestSuite(TestSuite $suite)
39
-    {
40
-    }
38
+	public function startTestSuite(TestSuite $suite)
39
+	{
40
+	}
41 41
 
42
-    public function endTestSuite(TestSuite $suite)
43
-    {
44
-    }
42
+	public function endTestSuite(TestSuite $suite)
43
+	{
44
+	}
45 45
 
46
-    public function startTest(Test $test)
47
-    {
48
-    }
46
+	public function startTest(Test $test)
47
+	{
48
+	}
49 49
 
50
-    public function endTest(Test $test, $time)
51
-    {
52
-    }
50
+	public function endTest(Test $test, $time)
51
+	{
52
+	}
53 53
 }
Please login to merge, or discard this patch.
vendor/phpunit/phpunit/src/Framework/ExceptionWrapper.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -23,71 +23,71 @@
 block discarded – undo
23 23
  */
24 24
 class ExceptionWrapper extends Exception
25 25
 {
26
-    /**
27
-     * @var string
28
-     */
29
-    protected $className;
26
+	/**
27
+	 * @var string
28
+	 */
29
+	protected $className;
30 30
 
31
-    /**
32
-     * @var ExceptionWrapper|null
33
-     */
34
-    protected $previous;
31
+	/**
32
+	 * @var ExceptionWrapper|null
33
+	 */
34
+	protected $previous;
35 35
 
36
-    /**
37
-     * @param Throwable $t
38
-     */
39
-    public function __construct(Throwable $t)
40
-    {
41
-        // PDOException::getCode() is a string.
42
-        // @see http://php.net/manual/en/class.pdoexception.php#95812
43
-        parent::__construct($t->getMessage(), (int) $t->getCode());
36
+	/**
37
+	 * @param Throwable $t
38
+	 */
39
+	public function __construct(Throwable $t)
40
+	{
41
+		// PDOException::getCode() is a string.
42
+		// @see http://php.net/manual/en/class.pdoexception.php#95812
43
+		parent::__construct($t->getMessage(), (int) $t->getCode());
44 44
 
45
-        $this->className = \get_class($t);
46
-        $this->file      = $t->getFile();
47
-        $this->line      = $t->getLine();
45
+		$this->className = \get_class($t);
46
+		$this->file      = $t->getFile();
47
+		$this->line      = $t->getLine();
48 48
 
49
-        $this->serializableTrace = $t->getTrace();
49
+		$this->serializableTrace = $t->getTrace();
50 50
 
51
-        foreach ($this->serializableTrace as $i => $call) {
52
-            unset($this->serializableTrace[$i]['args']);
53
-        }
51
+		foreach ($this->serializableTrace as $i => $call) {
52
+			unset($this->serializableTrace[$i]['args']);
53
+		}
54 54
 
55
-        if ($t->getPrevious()) {
56
-            $this->previous = new self($t->getPrevious());
57
-        }
58
-    }
55
+		if ($t->getPrevious()) {
56
+			$this->previous = new self($t->getPrevious());
57
+		}
58
+	}
59 59
 
60
-    /**
61
-     * @return string
62
-     */
63
-    public function getClassName()
64
-    {
65
-        return $this->className;
66
-    }
60
+	/**
61
+	 * @return string
62
+	 */
63
+	public function getClassName()
64
+	{
65
+		return $this->className;
66
+	}
67 67
 
68
-    /**
69
-     * @return ExceptionWrapper
70
-     */
71
-    public function getPreviousWrapped()
72
-    {
73
-        return $this->previous;
74
-    }
68
+	/**
69
+	 * @return ExceptionWrapper
70
+	 */
71
+	public function getPreviousWrapped()
72
+	{
73
+		return $this->previous;
74
+	}
75 75
 
76
-    /**
77
-     * @return string
78
-     */
79
-    public function __toString()
80
-    {
81
-        $string = TestFailure::exceptionToString($this);
76
+	/**
77
+	 * @return string
78
+	 */
79
+	public function __toString()
80
+	{
81
+		$string = TestFailure::exceptionToString($this);
82 82
 
83
-        if ($trace = Filter::getFilteredStacktrace($this)) {
84
-            $string .= "\n" . $trace;
85
-        }
83
+		if ($trace = Filter::getFilteredStacktrace($this)) {
84
+			$string .= "\n" . $trace;
85
+		}
86 86
 
87
-        if ($this->previous) {
88
-            $string .= "\nCaused by\n" . $this->previous;
89
-        }
87
+		if ($this->previous) {
88
+			$string .= "\nCaused by\n" . $this->previous;
89
+		}
90 90
 
91
-        return $string;
92
-    }
91
+		return $string;
92
+	}
93 93
 }
Please login to merge, or discard this patch.