]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/PHPUnit/PHPUnit/TextUI/TestRunner.php
Release 6.2.0
[Github/sugarcrm.git] / tests / PHPUnit / PHPUnit / TextUI / TestRunner.php
1 <?php
2 /**
3  * PHPUnit
4  *
5  * Copyright (c) 2002-2011, Sebastian Bergmann <sebastian@phpunit.de>.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  *   * Redistributions of source code must retain the above copyright
13  *     notice, this list of conditions and the following disclaimer.
14  *
15  *   * Redistributions in binary form must reproduce the above copyright
16  *     notice, this list of conditions and the following disclaimer in
17  *     the documentation and/or other materials provided with the
18  *     distribution.
19  *
20  *   * Neither the name of Sebastian Bergmann nor the names of his
21  *     contributors may be used to endorse or promote products derived
22  *     from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * @package    PHPUnit
38  * @subpackage TextUI
39  * @author     Sebastian Bergmann <sebastian@phpunit.de>
40  * @copyright  2002-2011 Sebastian Bergmann <sebastian@phpunit.de>
41  * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
42  * @link       http://www.phpunit.de/
43  * @since      File available since Release 2.0.0
44  */
45
46 /**
47  * A TestRunner for the Command Line Interface (CLI)
48  * PHP SAPI Module.
49  *
50  * @package    PHPUnit
51  * @subpackage TextUI
52  * @author     Sebastian Bergmann <sebastian@phpunit.de>
53  * @copyright  2002-2011 Sebastian Bergmann <sebastian@phpunit.de>
54  * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
55  * @version    Release: 3.5.13
56  * @link       http://www.phpunit.de/
57  * @since      Class available since Release 2.0.0
58  */
59 class PHPUnit_TextUI_TestRunner extends PHPUnit_Runner_BaseTestRunner
60 {
61     const SUCCESS_EXIT   = 0;
62     const FAILURE_EXIT   = 1;
63     const EXCEPTION_EXIT = 2;
64
65     /**
66      * @var    PHPUnit_Runner_TestSuiteLoader
67      */
68     protected $loader = NULL;
69
70     /**
71      * @var    PHPUnit_TextUI_ResultPrinter
72      */
73     protected $printer = NULL;
74
75     /**
76      * @var    boolean
77      */
78     protected static $versionStringPrinted = FALSE;
79
80     /**
81      * @param  PHPUnit_Runner_TestSuiteLoader $loader
82      * @since  Method available since Release 3.4.0
83      */
84     public function __construct(PHPUnit_Runner_TestSuiteLoader $loader = NULL)
85     {
86         $this->loader = $loader;
87     }
88
89     /**
90      * @param  mixed $test
91      * @param  array $arguments
92      * @throws InvalidArgumentException
93      */
94     public static function run($test, array $arguments = array())
95     {
96         if ($test instanceof ReflectionClass) {
97             $test = new PHPUnit_Framework_TestSuite($test);
98         }
99
100         if ($test instanceof PHPUnit_Framework_Test) {
101             $aTestRunner = new PHPUnit_TextUI_TestRunner;
102
103             return $aTestRunner->doRun(
104               $test,
105               $arguments
106             );
107         } else {
108             throw new InvalidArgumentException(
109               'No test case or test suite found.'
110             );
111         }
112     }
113
114     /**
115      * Runs a single test and waits until the user types RETURN.
116      *
117      * @param  PHPUnit_Framework_Test $suite
118      */
119     public static function runAndWait(PHPUnit_Framework_Test $suite)
120     {
121         $aTestRunner = new PHPUnit_TextUI_TestRunner;
122
123         $aTestRunner->doRun(
124           $suite,
125           array(
126             'wait' => TRUE
127           )
128         );
129
130     }
131
132     /**
133      * @return PHPUnit_Framework_TestResult
134      */
135     protected function createTestResult()
136     {
137         return new PHPUnit_Framework_TestResult;
138     }
139
140     /**
141      * @param  PHPUnit_Framework_Test $suite
142      * @param  array                  $arguments
143      * @return PHPUnit_Framework_TestResult
144      */
145     public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
146     {
147         $this->handleConfiguration($arguments);
148
149         if (isset($arguments['bootstrap'])) {
150             $GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap'];
151         }
152
153         if ($arguments['backupGlobals'] === FALSE) {
154             $suite->setBackupGlobals(FALSE);
155         }
156
157         if ($arguments['backupStaticAttributes'] === TRUE) {
158             $suite->setBackupStaticAttributes(TRUE);
159         }
160
161         if (is_integer($arguments['repeat'])) {
162             $suite = new PHPUnit_Extensions_RepeatedTest(
163               $suite,
164               $arguments['repeat'],
165               $arguments['filter'],
166               $arguments['groups'],
167               $arguments['excludeGroups'],
168               $arguments['processIsolation']
169             );
170         }
171
172         $result = $this->createTestResult();
173
174         if (!$arguments['convertErrorsToExceptions']) {
175             $result->convertErrorsToExceptions(FALSE);
176         }
177
178         if (!$arguments['convertNoticesToExceptions']) {
179             PHPUnit_Framework_Error_Notice::$enabled = FALSE;
180         }
181
182         if (!$arguments['convertWarningsToExceptions']) {
183             PHPUnit_Framework_Error_Warning::$enabled = FALSE;
184         }
185
186         if ($arguments['stopOnError']) {
187             $result->stopOnError(TRUE);
188         }
189
190         if ($arguments['stopOnFailure']) {
191             $result->stopOnFailure(TRUE);
192         }
193
194         if ($arguments['stopOnIncomplete']) {
195             $result->stopOnIncomplete(TRUE);
196         }
197
198         if ($arguments['stopOnSkipped']) {
199             $result->stopOnSkipped(TRUE);
200         }
201
202         if ($this->printer === NULL) {
203             if (isset($arguments['printer']) &&
204                 $arguments['printer'] instanceof PHPUnit_Util_Printer) {
205                 $this->printer = $arguments['printer'];
206             } else {
207                 $this->printer = new PHPUnit_TextUI_ResultPrinter(
208                   NULL,
209                   $arguments['verbose'],
210                   $arguments['colors'],
211                   $arguments['debug']
212                 );
213             }
214         }
215
216         if (!$this->printer instanceof PHPUnit_Util_Log_TAP &&
217             !self::$versionStringPrinted) {
218             $this->printer->write(
219               PHPUnit_Runner_Version::getVersionString() . "\n\n"
220             );
221         }
222
223         foreach ($arguments['listeners'] as $listener) {
224             $result->addListener($listener);
225         }
226
227         $result->addListener($this->printer);
228
229         if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
230             $result->addListener(new PHPUnit_Util_DeprecatedFeature_Logger);
231         }
232
233         if (isset($arguments['storyHTMLFile'])) {
234             $result->addListener(
235               new PHPUnit_Extensions_Story_ResultPrinter_HTML(
236                 $arguments['storyHTMLFile']
237               )
238             );
239         }
240
241         if (isset($arguments['storyTextFile'])) {
242             $result->addListener(
243               new PHPUnit_Extensions_Story_ResultPrinter_Text(
244                 $arguments['storyTextFile']
245               )
246             );
247         }
248
249         if (isset($arguments['testdoxHTMLFile'])) {
250             $result->addListener(
251               new PHPUnit_Util_TestDox_ResultPrinter_HTML(
252                 $arguments['testdoxHTMLFile']
253               )
254             );
255         }
256
257         if (isset($arguments['testdoxTextFile'])) {
258             $result->addListener(
259               new PHPUnit_Util_TestDox_ResultPrinter_Text(
260                 $arguments['testdoxTextFile']
261               )
262             );
263         }
264
265         if ((isset($arguments['coverageClover']) ||
266              isset($arguments['reportDirectory'])) &&
267              extension_loaded('xdebug')) {
268             $result->collectCodeCoverageInformation(TRUE);
269         }
270
271         if (isset($arguments['logDbus'])) {
272             $result->addListener(new PHPUnit_Util_Log_DBUS);
273         }
274
275         if (isset($arguments['jsonLogfile'])) {
276             $result->addListener(
277               new PHPUnit_Util_Log_JSON($arguments['jsonLogfile'])
278             );
279         }
280
281         if (isset($arguments['tapLogfile'])) {
282             $result->addListener(
283               new PHPUnit_Util_Log_TAP($arguments['tapLogfile'])
284             );
285         }
286
287         if (isset($arguments['junitLogfile'])) {
288             $result->addListener(
289               new PHPUnit_Util_Log_JUnit(
290                 $arguments['junitLogfile'], $arguments['logIncompleteSkipped']
291               )
292             );
293         }
294
295         if ($arguments['strict']) {
296             $result->strictMode(TRUE);
297         }
298
299         $suite->run(
300           $result,
301           $arguments['filter'],
302           $arguments['groups'],
303           $arguments['excludeGroups'],
304           $arguments['processIsolation']
305         );
306
307         unset($suite);
308         $result->flushListeners();
309
310         if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
311             $this->printer->printResult($result);
312         }
313
314         if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
315             if (isset($arguments['coverageClover'])) {
316                 $this->printer->write(
317                   "\nWriting code coverage data to XML file, this may take " .
318                   'a moment.'
319                 );
320
321                 require_once 'PHP/CodeCoverage/Report/Clover.php';
322
323                 $writer = new PHP_CodeCoverage_Report_Clover;
324                 $writer->process(
325                   $result->getCodeCoverage(), $arguments['coverageClover']
326                 );
327
328                 $this->printer->write("\n");
329                 unset($writer);
330             }
331
332             if (isset($arguments['reportDirectory'])) {
333                 $this->printer->write(
334                   "\nGenerating code coverage report, this may take a moment."
335                 );
336
337                 $title = '';
338
339                 if (isset($arguments['configuration'])) {
340                     $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
341
342                     if (isset($loggingConfiguration['title'])) {
343                         $title = $loggingConfiguration['title'];
344                     }
345                 }
346
347                 require_once 'PHP/CodeCoverage/Report/HTML.php';
348
349                 $writer = new PHP_CodeCoverage_Report_HTML(
350                   array(
351                     'title'          => $title,
352                     'charset'        => $arguments['reportCharset'],
353                     'yui'            => $arguments['reportYUI'],
354                     'highlight'      => $arguments['reportHighlight'],
355                     'lowUpperBound'  => $arguments['reportLowUpperBound'],
356                     'highLowerBound' => $arguments['reportHighLowerBound'],
357                     'generator'      => ' and PHPUnit ' . PHPUnit_Runner_Version::id()
358                   )
359                 );
360
361                 $writer->process(
362                   $result->getCodeCoverage(), $arguments['reportDirectory']
363                 );
364
365                 $this->printer->write("\n");
366                 unset($writer);
367             }
368         }
369
370         $this->pause($arguments['wait']);
371
372         return $result;
373     }
374
375     /**
376      * @param  boolean $wait
377      */
378     protected function pause($wait)
379     {
380         if (!$wait) {
381             return;
382         }
383
384         if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
385             $this->printer->printWaitPrompt();
386         }
387
388         fgets(STDIN);
389     }
390
391     /**
392      * @param  PHPUnit_TextUI_ResultPrinter $resultPrinter
393      */
394     public function setPrinter(PHPUnit_TextUI_ResultPrinter $resultPrinter)
395     {
396         $this->printer = $resultPrinter;
397     }
398
399     /**
400      * Override to define how to handle a failed loading of
401      * a test suite.
402      *
403      * @param  string  $message
404      */
405     protected function runFailed($message)
406     {
407         self::printVersionString();
408         self::write($message);
409         exit(self::FAILURE_EXIT);
410     }
411
412     /**
413      * @param  string $buffer
414      * @since  Method available since Release 3.1.0
415      */
416     protected static function write($buffer)
417     {
418         if (PHP_SAPI != 'cli') {
419             $buffer = htmlspecialchars($buffer);
420         }
421
422         print $buffer;
423     }
424
425     /**
426      * Returns the loader to be used.
427      *
428      * @return PHPUnit_Runner_TestSuiteLoader
429      * @since  Method available since Release 2.2.0
430      */
431     public function getLoader()
432     {
433         if ($this->loader === NULL) {
434             $this->loader = new PHPUnit_Runner_StandardTestSuiteLoader;
435         }
436
437         return $this->loader;
438     }
439
440     /**
441      */
442     public static function showError($message)
443     {
444         self::printVersionString();
445         self::write($message . "\n");
446
447         exit(self::FAILURE_EXIT);
448     }
449
450     /**
451      */
452     public static function printVersionString()
453     {
454         if (!self::$versionStringPrinted) {
455             self::write(PHPUnit_Runner_Version::getVersionString() . "\n\n");
456             self::$versionStringPrinted = TRUE;
457         }
458     }
459
460     /**
461      * @param  array $arguments
462      * @since  Method available since Release 3.2.1
463      */
464     protected function handleConfiguration(array &$arguments)
465     {
466         if (isset($arguments['configuration']) &&
467             !$arguments['configuration'] instanceof PHPUnit_Util_Configuration) {
468             $arguments['configuration'] = PHPUnit_Util_Configuration::getInstance(
469               $arguments['configuration']
470             );
471         }
472
473         $arguments['debug']     = isset($arguments['debug'])     ? $arguments['debug']     : FALSE;
474         $arguments['filter']    = isset($arguments['filter'])    ? $arguments['filter']    : FALSE;
475         $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
476         $arguments['wait']      = isset($arguments['wait'])      ? $arguments['wait']      : FALSE;
477
478         if (isset($arguments['configuration'])) {
479             $arguments['configuration']->handlePHPConfiguration();
480
481             $phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
482
483             if (isset($phpunitConfiguration['backupGlobals']) &&
484                 !isset($arguments['backupGlobals'])) {
485                 $arguments['backupGlobals'] = $phpunitConfiguration['backupGlobals'];
486             }
487
488             if (isset($phpunitConfiguration['backupStaticAttributes']) &&
489                 !isset($arguments['backupStaticAttributes'])) {
490                 $arguments['backupStaticAttributes'] = $phpunitConfiguration['backupStaticAttributes'];
491             }
492
493             if (isset($phpunitConfiguration['bootstrap']) &&
494                 !isset($arguments['bootstrap'])) {
495                 $arguments['bootstrap'] = $phpunitConfiguration['bootstrap'];
496             }
497
498             if (isset($phpunitConfiguration['colors']) &&
499                 !isset($arguments['colors'])) {
500                 $arguments['colors'] = $phpunitConfiguration['colors'];
501             }
502
503             if (isset($phpunitConfiguration['convertErrorsToExceptions']) &&
504                 !isset($arguments['convertErrorsToExceptions'])) {
505                 $arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions'];
506             }
507
508             if (isset($phpunitConfiguration['convertNoticesToExceptions']) &&
509                 !isset($arguments['convertNoticesToExceptions'])) {
510                 $arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions'];
511             }
512
513             if (isset($phpunitConfiguration['convertWarningsToExceptions']) &&
514                 !isset($arguments['convertWarningsToExceptions'])) {
515                 $arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions'];
516             }
517
518             if (isset($phpunitConfiguration['processIsolation']) &&
519                 !isset($arguments['processIsolation'])) {
520                 $arguments['processIsolation'] = $phpunitConfiguration['processIsolation'];
521             }
522
523             if (isset($phpunitConfiguration['stopOnFailure']) &&
524                 !isset($arguments['stopOnFailure'])) {
525                 $arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
526             }
527
528             if (isset($phpunitConfiguration['strict']) &&
529                 !isset($arguments['strict'])) {
530                 $arguments['strict'] = $phpunitConfiguration['strict'];
531             }
532
533             if (isset($phpunitConfiguration['verbose']) &&
534                 !isset($arguments['verbose'])) {
535                 $arguments['verbose'] = $phpunitConfiguration['verbose'];
536             }
537
538             if (isset($phpunitConfiguration['forceCoversAnnotation']) &&
539                 !isset($arguments['forceCoversAnnotation'])) {
540                 $arguments['forceCoversAnnotation'] = $phpunitConfiguration['forceCoversAnnotation'];
541             }
542
543             if (isset($phpunitConfiguration['mapTestClassNameToCoveredClassName']) &&
544                 !isset($arguments['mapTestClassNameToCoveredClassName'])) {
545                 $arguments['mapTestClassNameToCoveredClassName'] = $phpunitConfiguration['mapTestClassNameToCoveredClassName'];
546             }
547
548             $groupConfiguration = $arguments['configuration']->getGroupConfiguration();
549
550             if (!empty($groupConfiguration['include']) &&
551                 !isset($arguments['groups'])) {
552                 $arguments['groups'] = $groupConfiguration['include'];
553             }
554
555             if (!empty($groupConfiguration['exclude']) &&
556                 !isset($arguments['excludeGroups'])) {
557                 $arguments['excludeGroups'] = $groupConfiguration['exclude'];
558             }
559
560             foreach ($arguments['configuration']->getListenerConfiguration() as $listener) {
561                 if (!class_exists($listener['class'], FALSE) &&
562                     $listener['file'] !== '') {
563                     $file = PHPUnit_Util_Filesystem::fileExistsInIncludePath(
564                       $listener['file']
565                     );
566
567                     if ($file !== FALSE) {
568                         require $file;
569                     }
570                 }
571
572                 if (class_exists($listener['class'], FALSE)) {
573                     if (count($listener['arguments']) == 0) {
574                         $listener = new $listener['class'];
575                     } else {
576                         $listenerClass = new ReflectionClass(
577                                            $listener['class']
578                                          );
579                         $listener      = $listenerClass->newInstanceArgs(
580                                            $listener['arguments']
581                                          );
582                     }
583
584                     if ($listener instanceof PHPUnit_Framework_TestListener) {
585                         $arguments['listeners'][] = $listener;
586                     }
587                 }
588             }
589
590             $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
591
592             if (isset($loggingConfiguration['coverage-html']) &&
593                 !isset($arguments['reportDirectory'])) {
594                 if (isset($loggingConfiguration['charset']) &&
595                     !isset($arguments['reportCharset'])) {
596                     $arguments['reportCharset'] = $loggingConfiguration['charset'];
597                 }
598
599                 if (isset($loggingConfiguration['yui']) &&
600                     !isset($arguments['reportYUI'])) {
601                     $arguments['reportYUI'] = $loggingConfiguration['yui'];
602                 }
603
604                 if (isset($loggingConfiguration['highlight']) &&
605                     !isset($arguments['reportHighlight'])) {
606                     $arguments['reportHighlight'] = $loggingConfiguration['highlight'];
607                 }
608
609                 if (isset($loggingConfiguration['lowUpperBound']) &&
610                     !isset($arguments['reportLowUpperBound'])) {
611                     $arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound'];
612                 }
613
614                 if (isset($loggingConfiguration['highLowerBound']) &&
615                     !isset($arguments['reportHighLowerBound'])) {
616                     $arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound'];
617                 }
618
619                 $arguments['reportDirectory'] = $loggingConfiguration['coverage-html'];
620             }
621
622             if (isset($loggingConfiguration['coverage-clover']) &&
623                 !isset($arguments['coverageClover'])) {
624                 $arguments['coverageClover'] = $loggingConfiguration['coverage-clover'];
625             }
626
627             if (isset($loggingConfiguration['json']) &&
628                 !isset($arguments['jsonLogfile'])) {
629                 $arguments['jsonLogfile'] = $loggingConfiguration['json'];
630             }
631
632             if (isset($loggingConfiguration['plain'])) {
633                 $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter(
634                   $loggingConfiguration['plain'], TRUE
635                 );
636             }
637
638             if (isset($loggingConfiguration['tap']) &&
639                 !isset($arguments['tapLogfile'])) {
640                 $arguments['tapLogfile'] = $loggingConfiguration['tap'];
641             }
642
643             if (isset($loggingConfiguration['junit']) &&
644                 !isset($arguments['junitLogfile'])) {
645                 $arguments['junitLogfile'] = $loggingConfiguration['junit'];
646
647                 if (isset($loggingConfiguration['logIncompleteSkipped']) &&
648                     !isset($arguments['logIncompleteSkipped'])) {
649                     $arguments['logIncompleteSkipped'] = $loggingConfiguration['logIncompleteSkipped'];
650                 }
651             }
652
653             if (isset($loggingConfiguration['story-html']) &&
654                 !isset($arguments['storyHTMLFile'])) {
655                 $arguments['storyHTMLFile'] = $loggingConfiguration['story-html'];
656             }
657
658             if (isset($loggingConfiguration['story-text']) &&
659                 !isset($arguments['storyTextFile'])) {
660                 $arguments['storsTextFile'] = $loggingConfiguration['story-text'];
661             }
662
663             if (isset($loggingConfiguration['testdox-html']) &&
664                 !isset($arguments['testdoxHTMLFile'])) {
665                 $arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html'];
666             }
667
668             if (isset($loggingConfiguration['testdox-text']) &&
669                 !isset($arguments['testdoxTextFile'])) {
670                 $arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text'];
671             }
672         }
673
674         if (isset($arguments['configuration'])) {
675             $filterConfiguration = $arguments['configuration']->getFilterConfiguration();
676
677             $filter = PHP_CodeCoverage_Filter::getInstance();
678
679             foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) {
680                 $filter->addDirectoryToBlacklist(
681                   $dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']
682                 );
683             }
684
685             foreach ($filterConfiguration['blacklist']['include']['file'] as $file) {
686                 $filter->addFileToBlacklist($file);
687             }
688
689             foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) {
690                 $filter->removeDirectoryFromBlacklist(
691                   $dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']
692                 );
693             }
694
695             foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) {
696                 $filter->removeFileFromBlacklist($file);
697             }
698
699             if ((isset($arguments['coverageClover']) ||
700                 isset($arguments['reportDirectory'])) &&
701                 extension_loaded('xdebug')) {
702                 $coverage = PHP_CodeCoverage::getInstance();
703
704                 $coverage->setProcessUncoveredFilesFromWhitelist(
705                   $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist']
706                 );
707
708                 if (isset($arguments['forceCoversAnnotation'])) {
709                     $coverage->setForceCoversAnnotation(
710                       $arguments['forceCoversAnnotation']
711                     );
712                 }
713
714                 if (isset($arguments['mapTestClassNameToCoveredClassName'])) {
715                     $coverage->setMapTestClassNameToCoveredClassName(
716                       $arguments['mapTestClassNameToCoveredClassName']
717                     );
718                 }
719
720                 foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
721                     $filter->addDirectoryToWhitelist(
722                       $dir['path'], $dir['suffix'], $dir['prefix']
723                     );
724                 }
725
726                 foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
727                     $filter->addFileToWhitelist($file);
728                 }
729
730                 foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
731                     $filter->removeDirectoryFromWhitelist(
732                       $dir['path'], $dir['suffix'], $dir['prefix']
733                     );
734                 }
735
736                 foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
737                     $filter->removeFileFromWhitelist($file);
738                 }
739             }
740         }
741
742         $arguments['backupGlobals']               = isset($arguments['backupGlobals'])               ? $arguments['backupGlobals']               : NULL;
743         $arguments['backupStaticAttributes']      = isset($arguments['backupStaticAttributes'])      ? $arguments['backupStaticAttributes']      : NULL;
744         $arguments['colors']                      = isset($arguments['colors'])                      ? $arguments['colors']                      : FALSE;
745         $arguments['convertErrorsToExceptions']   = isset($arguments['convertErrorsToExceptions'])   ? $arguments['convertErrorsToExceptions']   : TRUE;
746         $arguments['convertNoticesToExceptions']  = isset($arguments['convertNoticesToExceptions'])  ? $arguments['convertNoticesToExceptions']  : TRUE;
747         $arguments['convertWarningsToExceptions'] = isset($arguments['convertWarningsToExceptions']) ? $arguments['convertWarningsToExceptions'] : TRUE;
748         $arguments['excludeGroups']               = isset($arguments['excludeGroups'])               ? $arguments['excludeGroups']               : array();
749         $arguments['groups']                      = isset($arguments['groups'])                      ? $arguments['groups']                      : array();
750         $arguments['logIncompleteSkipped']        = isset($arguments['logIncompleteSkipped'])        ? $arguments['logIncompleteSkipped']        : FALSE;
751         $arguments['processIsolation']            = isset($arguments['processIsolation'])            ? $arguments['processIsolation']            : FALSE;
752         $arguments['repeat']                      = isset($arguments['repeat'])                      ? $arguments['repeat']                      : FALSE;
753         $arguments['reportCharset']               = isset($arguments['reportCharset'])               ? $arguments['reportCharset']               : 'UTF-8';
754         $arguments['reportHighlight']             = isset($arguments['reportHighlight'])             ? $arguments['reportHighlight']             : FALSE;
755         $arguments['reportHighLowerBound']        = isset($arguments['reportHighLowerBound'])        ? $arguments['reportHighLowerBound']        : 70;
756         $arguments['reportLowUpperBound']         = isset($arguments['reportLowUpperBound'])         ? $arguments['reportLowUpperBound']         : 35;
757         $arguments['reportYUI']                   = isset($arguments['reportYUI'])                   ? $arguments['reportYUI']                   : TRUE;
758         $arguments['stopOnError']                 = isset($arguments['stopOnError'])                 ? $arguments['stopOnError']                 : FALSE;
759         $arguments['stopOnFailure']               = isset($arguments['stopOnFailure'])               ? $arguments['stopOnFailure']               : FALSE;
760         $arguments['stopOnIncomplete']            = isset($arguments['stopOnIncomplete'])            ? $arguments['stopOnIncomplete']            : FALSE;
761         $arguments['stopOnSkipped']               = isset($arguments['stopOnSkipped'])               ? $arguments['stopOnSkipped']               : FALSE;
762         $arguments['strict']                      = isset($arguments['strict'])                      ? $arguments['strict']                      : FALSE;
763         $arguments['verbose']                     = isset($arguments['verbose'])                     ? $arguments['verbose']                     : FALSE;
764
765         if ($arguments['filter'] !== FALSE &&
766             preg_match('/^[a-zA-Z0-9_]/', $arguments['filter'])) {
767             // Escape delimiters in regular expression. Do NOT use preg_quote,
768             // to keep magic characters.
769             $arguments['filter'] = '/' . str_replace(
770               '/', '\\/', $arguments['filter']
771             ) . '/';
772         }
773     }
774 }