gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

TestRunner.php (33326B)


      1 <?php
      2 /**
      3  * PHPUnit
      4  *
      5  * Copyright (c) 2001-2014, 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  2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
     41  * @license    http://www.opensource.org/licenses/BSD-3-Clause  The BSD 3-Clause 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  2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
     54  * @license    http://www.opensource.org/licenses/BSD-3-Clause  The BSD 3-Clause License
     55  * @link       http://www.phpunit.de/
     56  * @since      Class available since Release 2.0.0
     57  */
     58 class PHPUnit_TextUI_TestRunner extends PHPUnit_Runner_BaseTestRunner
     59 {
     60     const SUCCESS_EXIT   = 0;
     61     const FAILURE_EXIT   = 1;
     62     const EXCEPTION_EXIT = 2;
     63 
     64     /**
     65      * @var PHP_CodeCoverage_Filter
     66      */
     67     protected $codeCoverageFilter;
     68 
     69     /**
     70      * @var PHPUnit_Runner_TestSuiteLoader
     71      */
     72     protected $loader = NULL;
     73 
     74     /**
     75      * @var PHPUnit_TextUI_ResultPrinter
     76      */
     77     protected $printer = NULL;
     78 
     79     /**
     80      * @var boolean
     81      */
     82     protected static $versionStringPrinted = FALSE;
     83 
     84     /**
     85      * @param PHPUnit_Runner_TestSuiteLoader $loader
     86      * @param PHP_CodeCoverage_Filter        $filter
     87      * @since Method available since Release 3.4.0
     88      */
     89     public function __construct(PHPUnit_Runner_TestSuiteLoader $loader = NULL, PHP_CodeCoverage_Filter $filter = NULL)
     90     {
     91         if ($filter === NULL) {
     92             $filter = new PHP_CodeCoverage_Filter;
     93         }
     94 
     95         $this->codeCoverageFilter = $filter;
     96         $this->loader             = $loader;
     97     }
     98 
     99     /**
    100      * @param  mixed $test
    101      * @param  array $arguments
    102      * @throws PHPUnit_Framework_Exception
    103      */
    104     public static function run($test, array $arguments = array())
    105     {
    106         if ($test instanceof ReflectionClass) {
    107             $test = new PHPUnit_Framework_TestSuite($test);
    108         }
    109 
    110         if ($test instanceof PHPUnit_Framework_Test) {
    111             $aTestRunner = new PHPUnit_TextUI_TestRunner;
    112 
    113             return $aTestRunner->doRun(
    114               $test,
    115               $arguments
    116             );
    117         } else {
    118             throw new PHPUnit_Framework_Exception(
    119               'No test case or test suite found.'
    120             );
    121         }
    122     }
    123 
    124     /**
    125      * @return PHPUnit_Framework_TestResult
    126      */
    127     protected function createTestResult()
    128     {
    129         return new PHPUnit_Framework_TestResult;
    130     }
    131 
    132     /**
    133      * @param  PHPUnit_Framework_Test $suite
    134      * @param  array                  $arguments
    135      * @return PHPUnit_Framework_TestResult
    136      */
    137     public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
    138     {
    139         $this->handleConfiguration($arguments);
    140 
    141         if (isset($arguments['bootstrap'])) {
    142             $GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap'];
    143         }
    144 
    145         if ($arguments['backupGlobals'] === FALSE) {
    146             $suite->setBackupGlobals(FALSE);
    147         }
    148 
    149         if ($arguments['backupStaticAttributes'] === TRUE) {
    150             $suite->setBackupStaticAttributes(TRUE);
    151         }
    152 
    153         if (is_integer($arguments['repeat'])) {
    154             $test = new PHPUnit_Extensions_RepeatedTest(
    155               $suite,
    156               $arguments['repeat'],
    157               $arguments['filter'],
    158               $arguments['groups'],
    159               $arguments['excludeGroups'],
    160               $arguments['processIsolation']
    161             );
    162 
    163             $suite = new PHPUnit_Framework_TestSuite();
    164             $suite->addTest($test);
    165         }
    166 
    167         $result = $this->createTestResult();
    168 
    169         if (!$arguments['convertErrorsToExceptions']) {
    170             $result->convertErrorsToExceptions(FALSE);
    171         }
    172 
    173         if (!$arguments['convertNoticesToExceptions']) {
    174             PHPUnit_Framework_Error_Notice::$enabled = FALSE;
    175         }
    176 
    177         if (!$arguments['convertWarningsToExceptions']) {
    178             PHPUnit_Framework_Error_Warning::$enabled = FALSE;
    179         }
    180 
    181         if ($arguments['stopOnError']) {
    182             $result->stopOnError(TRUE);
    183         }
    184 
    185         if ($arguments['stopOnFailure']) {
    186             $result->stopOnFailure(TRUE);
    187         }
    188 
    189         if ($arguments['stopOnIncomplete']) {
    190             $result->stopOnIncomplete(TRUE);
    191         }
    192 
    193         if ($arguments['stopOnSkipped']) {
    194             $result->stopOnSkipped(TRUE);
    195         }
    196 
    197         if ($this->printer === NULL) {
    198             if (isset($arguments['printer']) &&
    199                 $arguments['printer'] instanceof PHPUnit_Util_Printer) {
    200                 $this->printer = $arguments['printer'];
    201             } else {
    202                 $this->printer = new PHPUnit_TextUI_ResultPrinter(
    203                   NULL,
    204                   $arguments['verbose'],
    205                   $arguments['colors'],
    206                   $arguments['debug']
    207                 );
    208             }
    209         }
    210 
    211         if (!$this->printer instanceof PHPUnit_Util_Log_TAP) {
    212             $this->printer->write(
    213               PHPUnit_Runner_Version::getVersionString() . "\n\n"
    214             );
    215 
    216             self::$versionStringPrinted = TRUE;
    217 
    218             if (isset($arguments['configuration'])) {
    219                 $this->printer->write(
    220                   sprintf(
    221                     "Configuration read from %s\n\n",
    222                     $arguments['configuration']->getFilename()
    223                   )
    224                 );
    225             }
    226         }
    227 
    228         foreach ($arguments['listeners'] as $listener) {
    229             $result->addListener($listener);
    230         }
    231 
    232         $result->addListener($this->printer);
    233 
    234         if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
    235             $result->addListener(new PHPUnit_Util_DeprecatedFeature_Logger);
    236         }
    237 
    238         if (isset($arguments['testdoxHTMLFile'])) {
    239             $result->addListener(
    240               new PHPUnit_Util_TestDox_ResultPrinter_HTML(
    241                 $arguments['testdoxHTMLFile']
    242               )
    243             );
    244         }
    245 
    246         if (isset($arguments['testdoxTextFile'])) {
    247             $result->addListener(
    248               new PHPUnit_Util_TestDox_ResultPrinter_Text(
    249                 $arguments['testdoxTextFile']
    250               )
    251             );
    252         }
    253 
    254         $codeCoverageReports = 0;
    255 
    256         if (extension_loaded('xdebug')) {
    257             if (isset($arguments['coverageClover'])) {
    258                 $codeCoverageReports++;
    259             }
    260 
    261             if (isset($arguments['reportDirectory'])) {
    262                 $codeCoverageReports++;
    263             }
    264 
    265             if (isset($arguments['coveragePHP'])) {
    266                 $codeCoverageReports++;
    267             }
    268 
    269             if (isset($arguments['coverageText'])) {
    270                 $codeCoverageReports++;
    271             }
    272         }
    273 
    274         if ($codeCoverageReports > 0) {
    275             $codeCoverage = new PHP_CodeCoverage(
    276               NULL, $this->codeCoverageFilter
    277             );
    278 
    279             $codeCoverage->setAddUncoveredFilesFromWhitelist(
    280               $arguments['addUncoveredFilesFromWhitelist']
    281             );
    282 
    283             $codeCoverage->setProcessUncoveredFilesFromWhitelist(
    284               $arguments['processUncoveredFilesFromWhitelist']
    285             );
    286 
    287             if (isset($arguments['forceCoversAnnotation'])) {
    288                 $codeCoverage->setForceCoversAnnotation(
    289                   $arguments['forceCoversAnnotation']
    290                 );
    291             }
    292 
    293             if (isset($arguments['mapTestClassNameToCoveredClassName'])) {
    294                 $codeCoverage->setMapTestClassNameToCoveredClassName(
    295                   $arguments['mapTestClassNameToCoveredClassName']
    296                 );
    297             }
    298 
    299             $result->setCodeCoverage($codeCoverage);
    300         }
    301 
    302         if ($codeCoverageReports > 1) {
    303             if (isset($arguments['cacheTokens'])) {
    304                 $codeCoverage->setCacheTokens($arguments['cacheTokens']);
    305             }
    306         }
    307 
    308         if (isset($arguments['jsonLogfile'])) {
    309             $result->addListener(
    310               new PHPUnit_Util_Log_JSON($arguments['jsonLogfile'])
    311             );
    312         }
    313 
    314         if (isset($arguments['tapLogfile'])) {
    315             $result->addListener(
    316               new PHPUnit_Util_Log_TAP($arguments['tapLogfile'])
    317             );
    318         }
    319 
    320         if (isset($arguments['junitLogfile'])) {
    321             $result->addListener(
    322               new PHPUnit_Util_Log_JUnit(
    323                 $arguments['junitLogfile'], $arguments['logIncompleteSkipped']
    324               )
    325             );
    326         }
    327 
    328         if ($arguments['strict']) {
    329             $result->strictMode(TRUE);
    330 
    331             $result->setTimeoutForSmallTests(
    332               $arguments['timeoutForSmallTests']
    333             );
    334 
    335             $result->setTimeoutForMediumTests(
    336               $arguments['timeoutForMediumTests']
    337             );
    338 
    339             $result->setTimeoutForLargeTests(
    340               $arguments['timeoutForLargeTests']
    341             );
    342         }
    343 
    344         $suite->run(
    345           $result,
    346           $arguments['filter'],
    347           $arguments['groups'],
    348           $arguments['excludeGroups'],
    349           $arguments['processIsolation']
    350         );
    351 
    352         unset($suite);
    353         $result->flushListeners();
    354 
    355         if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
    356             $this->printer->printResult($result);
    357         }
    358 
    359         if (isset($codeCoverage)) {
    360             if (isset($arguments['coverageClover'])) {
    361                 $this->printer->write(
    362                   "\nGenerating code coverage report in Clover XML format ..."
    363                 );
    364 
    365                 $writer = new PHP_CodeCoverage_Report_Clover;
    366                 $writer->process($codeCoverage, $arguments['coverageClover']);
    367 
    368                 $this->printer->write(" done\n");
    369                 unset($writer);
    370             }
    371 
    372             if (isset($arguments['reportDirectory'])) {
    373                 $this->printer->write(
    374                   "\nGenerating code coverage report in HTML format ..."
    375                 );
    376 
    377                 $writer = new PHP_CodeCoverage_Report_HTML(
    378                   $arguments['reportCharset'],
    379                   $arguments['reportHighlight'],
    380                   $arguments['reportLowUpperBound'],
    381                   $arguments['reportHighLowerBound'],
    382                   sprintf(
    383                     ' and <a href="http://phpunit.de/">PHPUnit %s</a>',
    384                     PHPUnit_Runner_Version::id()
    385                   )
    386                 );
    387 
    388                 $writer->process($codeCoverage, $arguments['reportDirectory']);
    389 
    390                 $this->printer->write(" done\n");
    391                 unset($writer);
    392             }
    393 
    394             if (isset($arguments['coveragePHP'])) {
    395                 $this->printer->write(
    396                   "\nGenerating code coverage report in PHP format ..."
    397                 );
    398 
    399                 $writer = new PHP_CodeCoverage_Report_PHP;
    400                 $writer->process($codeCoverage, $arguments['coveragePHP']);
    401 
    402                 $this->printer->write(" done\n");
    403                 unset($writer);
    404             }
    405 
    406             if (isset($arguments['coverageText'])) {
    407                 if ($arguments['coverageText'] == 'php://stdout') {
    408                     $outputStream = $this->printer;
    409                     $colors       = (bool)$arguments['colors'];
    410                 } else {
    411                     $outputStream = new PHPUnit_Util_Printer($arguments['coverageText']);
    412                     $colors       = FALSE;
    413                 }
    414 
    415                 $writer = new PHP_CodeCoverage_Report_Text(
    416                   $outputStream,
    417                   $arguments['reportLowUpperBound'],
    418                   $arguments['reportHighLowerBound'],
    419                   $arguments['coverageTextShowUncoveredFiles']
    420                 );
    421 
    422                 $writer->process($codeCoverage, $colors);
    423             }
    424         }
    425 
    426         return $result;
    427     }
    428 
    429     /**
    430      * @param  PHPUnit_TextUI_ResultPrinter $resultPrinter
    431      */
    432     public function setPrinter(PHPUnit_TextUI_ResultPrinter $resultPrinter)
    433     {
    434         $this->printer = $resultPrinter;
    435     }
    436 
    437     /**
    438      * Override to define how to handle a failed loading of
    439      * a test suite.
    440      *
    441      * @param  string  $message
    442      */
    443     protected function runFailed($message)
    444     {
    445         self::printVersionString();
    446         self::write($message . PHP_EOL);
    447         exit(self::FAILURE_EXIT);
    448     }
    449 
    450     /**
    451      * @param  string $buffer
    452      * @since  Method available since Release 3.1.0
    453      */
    454     protected static function write($buffer)
    455     {
    456         if (PHP_SAPI != 'cli') {
    457             $buffer = htmlspecialchars($buffer);
    458         }
    459 
    460         print $buffer;
    461     }
    462 
    463     /**
    464      * Returns the loader to be used.
    465      *
    466      * @return PHPUnit_Runner_TestSuiteLoader
    467      * @since  Method available since Release 2.2.0
    468      */
    469     public function getLoader()
    470     {
    471         if ($this->loader === NULL) {
    472             $this->loader = new PHPUnit_Runner_StandardTestSuiteLoader;
    473         }
    474 
    475         return $this->loader;
    476     }
    477 
    478     /**
    479      */
    480     public static function showError($message)
    481     {
    482         self::printVersionString();
    483         self::write($message . "\n");
    484 
    485         exit(self::FAILURE_EXIT);
    486     }
    487 
    488     /**
    489      */
    490     public static function printVersionString()
    491     {
    492         if (!self::$versionStringPrinted) {
    493             self::write(PHPUnit_Runner_Version::getVersionString() . "\n\n");
    494             self::$versionStringPrinted = TRUE;
    495         }
    496     }
    497 
    498     /**
    499      * @param  array $arguments
    500      * @since  Method available since Release 3.2.1
    501      */
    502     protected function handleConfiguration(array &$arguments)
    503     {
    504         if (isset($arguments['configuration']) &&
    505             !$arguments['configuration'] instanceof PHPUnit_Util_Configuration) {
    506             $arguments['configuration'] = PHPUnit_Util_Configuration::getInstance(
    507               $arguments['configuration']
    508             );
    509         }
    510 
    511         $arguments['debug']     = isset($arguments['debug'])     ? $arguments['debug']     : FALSE;
    512         $arguments['filter']    = isset($arguments['filter'])    ? $arguments['filter']    : FALSE;
    513         $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
    514 
    515         if (isset($arguments['configuration'])) {
    516             $arguments['configuration']->handlePHPConfiguration();
    517 
    518             $phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
    519 
    520             if (isset($phpunitConfiguration['backupGlobals']) &&
    521                 !isset($arguments['backupGlobals'])) {
    522                 $arguments['backupGlobals'] = $phpunitConfiguration['backupGlobals'];
    523             }
    524 
    525             if (isset($phpunitConfiguration['backupStaticAttributes']) &&
    526                 !isset($arguments['backupStaticAttributes'])) {
    527                 $arguments['backupStaticAttributes'] = $phpunitConfiguration['backupStaticAttributes'];
    528             }
    529 
    530             if (isset($phpunitConfiguration['bootstrap']) &&
    531                 !isset($arguments['bootstrap'])) {
    532                 $arguments['bootstrap'] = $phpunitConfiguration['bootstrap'];
    533             }
    534 
    535             if (isset($phpunitConfiguration['cacheTokens']) &&
    536                 !isset($arguments['cacheTokens'])) {
    537                 $arguments['cacheTokens'] = $phpunitConfiguration['cacheTokens'];
    538             }
    539 
    540             if (isset($phpunitConfiguration['colors']) &&
    541                 !isset($arguments['colors'])) {
    542                 $arguments['colors'] = $phpunitConfiguration['colors'];
    543             }
    544 
    545             if (isset($phpunitConfiguration['convertErrorsToExceptions']) &&
    546                 !isset($arguments['convertErrorsToExceptions'])) {
    547                 $arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions'];
    548             }
    549 
    550             if (isset($phpunitConfiguration['convertNoticesToExceptions']) &&
    551                 !isset($arguments['convertNoticesToExceptions'])) {
    552                 $arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions'];
    553             }
    554 
    555             if (isset($phpunitConfiguration['convertWarningsToExceptions']) &&
    556                 !isset($arguments['convertWarningsToExceptions'])) {
    557                 $arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions'];
    558             }
    559 
    560             if (isset($phpunitConfiguration['processIsolation']) &&
    561                 !isset($arguments['processIsolation'])) {
    562                 $arguments['processIsolation'] = $phpunitConfiguration['processIsolation'];
    563             }
    564 
    565             if (isset($phpunitConfiguration['stopOnFailure']) &&
    566                 !isset($arguments['stopOnFailure'])) {
    567                 $arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
    568             }
    569 
    570             if (isset($phpunitConfiguration['timeoutForSmallTests']) &&
    571                 !isset($arguments['timeoutForSmallTests'])) {
    572                 $arguments['timeoutForSmallTests'] = $phpunitConfiguration['timeoutForSmallTests'];
    573             }
    574 
    575             if (isset($phpunitConfiguration['timeoutForMediumTests']) &&
    576                 !isset($arguments['timeoutForMediumTests'])) {
    577                 $arguments['timeoutForMediumTests'] = $phpunitConfiguration['timeoutForMediumTests'];
    578             }
    579 
    580             if (isset($phpunitConfiguration['timeoutForLargeTests']) &&
    581                 !isset($arguments['timeoutForLargeTests'])) {
    582                 $arguments['timeoutForLargeTests'] = $phpunitConfiguration['timeoutForLargeTests'];
    583             }
    584 
    585             if (isset($phpunitConfiguration['strict']) &&
    586                 !isset($arguments['strict'])) {
    587                 $arguments['strict'] = $phpunitConfiguration['strict'];
    588             }
    589 
    590             if (isset($phpunitConfiguration['verbose']) &&
    591                 !isset($arguments['verbose'])) {
    592                 $arguments['verbose'] = $phpunitConfiguration['verbose'];
    593             }
    594 
    595             if (isset($phpunitConfiguration['forceCoversAnnotation']) &&
    596                 !isset($arguments['forceCoversAnnotation'])) {
    597                 $arguments['forceCoversAnnotation'] = $phpunitConfiguration['forceCoversAnnotation'];
    598             }
    599 
    600             if (isset($phpunitConfiguration['mapTestClassNameToCoveredClassName']) &&
    601                 !isset($arguments['mapTestClassNameToCoveredClassName'])) {
    602                 $arguments['mapTestClassNameToCoveredClassName'] = $phpunitConfiguration['mapTestClassNameToCoveredClassName'];
    603             }
    604 
    605             $groupCliArgs = array();
    606             if (!empty($arguments['groups'])) {
    607                 $groupCliArgs = $arguments['groups'];
    608             }
    609 
    610             $groupConfiguration = $arguments['configuration']->getGroupConfiguration();
    611 
    612             if (!empty($groupConfiguration['include']) &&
    613                 !isset($arguments['groups'])) {
    614                 $arguments['groups'] = $groupConfiguration['include'];
    615             }
    616 
    617             if (!empty($groupConfiguration['exclude']) &&
    618                 !isset($arguments['excludeGroups'])) {
    619                 $arguments['excludeGroups'] = array_diff($groupConfiguration['exclude'], $groupCliArgs);
    620             }
    621 
    622             foreach ($arguments['configuration']->getListenerConfiguration() as $listener) {
    623                 if (!class_exists($listener['class'], FALSE) &&
    624                     $listener['file'] !== '') {
    625                     require_once $listener['file'];
    626                 }
    627 
    628                 if (class_exists($listener['class'])) {
    629                     if (count($listener['arguments']) == 0) {
    630                         $listener = new $listener['class'];
    631                     } else {
    632                         $listenerClass = new ReflectionClass(
    633                                            $listener['class']
    634                                          );
    635                         $listener      = $listenerClass->newInstanceArgs(
    636                                            $listener['arguments']
    637                                          );
    638                     }
    639 
    640                     if ($listener instanceof PHPUnit_Framework_TestListener) {
    641                         $arguments['listeners'][] = $listener;
    642                     }
    643                 }
    644             }
    645 
    646             $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
    647 
    648             if (isset($loggingConfiguration['coverage-html']) &&
    649                 !isset($arguments['reportDirectory'])) {
    650                 if (isset($loggingConfiguration['charset']) &&
    651                     !isset($arguments['reportCharset'])) {
    652                     $arguments['reportCharset'] = $loggingConfiguration['charset'];
    653                 }
    654 
    655                 if (isset($loggingConfiguration['highlight']) &&
    656                     !isset($arguments['reportHighlight'])) {
    657                     $arguments['reportHighlight'] = $loggingConfiguration['highlight'];
    658                 }
    659 
    660                 if (isset($loggingConfiguration['lowUpperBound']) &&
    661                     !isset($arguments['reportLowUpperBound'])) {
    662                     $arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound'];
    663                 }
    664 
    665                 if (isset($loggingConfiguration['highLowerBound']) &&
    666                     !isset($arguments['reportHighLowerBound'])) {
    667                     $arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound'];
    668                 }
    669 
    670                 $arguments['reportDirectory'] = $loggingConfiguration['coverage-html'];
    671             }
    672 
    673             if (isset($loggingConfiguration['coverage-clover']) &&
    674                 !isset($arguments['coverageClover'])) {
    675                 $arguments['coverageClover'] = $loggingConfiguration['coverage-clover'];
    676             }
    677 
    678             if (isset($loggingConfiguration['coverage-php']) &&
    679                 !isset($arguments['coveragePHP'])) {
    680                 $arguments['coveragePHP'] = $loggingConfiguration['coverage-php'];
    681             }
    682 
    683             if (isset($loggingConfiguration['coverage-text']) &&
    684                 !isset($arguments['coverageText'])) {
    685                 $arguments['coverageText'] = $loggingConfiguration['coverage-text'];
    686                 if (isset($loggingConfiguration['coverageTextShowUncoveredFiles'])) {
    687                     $arguments['coverageTextShowUncoveredFiles'] = $loggingConfiguration['coverageTextShowUncoveredFiles'];
    688                 } else {
    689                     $arguments['coverageTextShowUncoveredFiles'] = FALSE;
    690                 }
    691             }
    692 
    693             if (isset($loggingConfiguration['json']) &&
    694                 !isset($arguments['jsonLogfile'])) {
    695                 $arguments['jsonLogfile'] = $loggingConfiguration['json'];
    696             }
    697 
    698             if (isset($loggingConfiguration['plain'])) {
    699                 $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter(
    700                   $loggingConfiguration['plain'], TRUE
    701                 );
    702             }
    703 
    704             if (isset($loggingConfiguration['tap']) &&
    705                 !isset($arguments['tapLogfile'])) {
    706                 $arguments['tapLogfile'] = $loggingConfiguration['tap'];
    707             }
    708 
    709             if (isset($loggingConfiguration['junit']) &&
    710                 !isset($arguments['junitLogfile'])) {
    711                 $arguments['junitLogfile'] = $loggingConfiguration['junit'];
    712 
    713                 if (isset($loggingConfiguration['logIncompleteSkipped']) &&
    714                     !isset($arguments['logIncompleteSkipped'])) {
    715                     $arguments['logIncompleteSkipped'] = $loggingConfiguration['logIncompleteSkipped'];
    716                 }
    717             }
    718 
    719             if (isset($loggingConfiguration['testdox-html']) &&
    720                 !isset($arguments['testdoxHTMLFile'])) {
    721                 $arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html'];
    722             }
    723 
    724             if (isset($loggingConfiguration['testdox-text']) &&
    725                 !isset($arguments['testdoxTextFile'])) {
    726                 $arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text'];
    727             }
    728 
    729             if ((isset($arguments['coverageClover']) ||
    730                 isset($arguments['reportDirectory']) ||
    731                 isset($arguments['coveragePHP']) ||
    732                 isset($arguments['coverageText'])) &&
    733                 extension_loaded('xdebug')) {
    734 
    735                 $filterConfiguration = $arguments['configuration']->getFilterConfiguration();
    736                 $arguments['addUncoveredFilesFromWhitelist'] = $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist'];
    737                 $arguments['processUncoveredFilesFromWhitelist'] = $filterConfiguration['whitelist']['processUncoveredFilesFromWhitelist'];
    738 
    739                 foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) {
    740                     $this->codeCoverageFilter->addDirectoryToBlacklist(
    741                       $dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']
    742                     );
    743                 }
    744 
    745                 foreach ($filterConfiguration['blacklist']['include']['file'] as $file) {
    746                     $this->codeCoverageFilter->addFileToBlacklist($file);
    747                 }
    748 
    749                 foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) {
    750                     $this->codeCoverageFilter->removeDirectoryFromBlacklist(
    751                       $dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']
    752                     );
    753                 }
    754 
    755                 foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) {
    756                     $this->codeCoverageFilter->removeFileFromBlacklist($file);
    757                 }
    758 
    759                 foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
    760                     $this->codeCoverageFilter->addDirectoryToWhitelist(
    761                       $dir['path'], $dir['suffix'], $dir['prefix']
    762                     );
    763                 }
    764 
    765                 foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
    766                     $this->codeCoverageFilter->addFileToWhitelist($file);
    767                 }
    768 
    769                 foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
    770                     $this->codeCoverageFilter->removeDirectoryFromWhitelist(
    771                       $dir['path'], $dir['suffix'], $dir['prefix']
    772                     );
    773                 }
    774 
    775                 foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
    776                     $this->codeCoverageFilter->removeFileFromWhitelist($file);
    777                 }
    778             }
    779         }
    780 
    781         $arguments['addUncoveredFilesFromWhitelist']     = isset($arguments['addUncoveredFilesFromWhitelist'])     ? $arguments['addUncoveredFilesFromWhitelist']     : TRUE;
    782         $arguments['processUncoveredFilesFromWhitelist'] = isset($arguments['processUncoveredFilesFromWhitelist']) ? $arguments['processUncoveredFilesFromWhitelist'] : FALSE;
    783         $arguments['backupGlobals']                      = isset($arguments['backupGlobals'])                      ? $arguments['backupGlobals']                      : NULL;
    784         $arguments['backupStaticAttributes']             = isset($arguments['backupStaticAttributes'])             ? $arguments['backupStaticAttributes']             : NULL;
    785         $arguments['cacheTokens']                        = isset($arguments['cacheTokens'])                        ? $arguments['cacheTokens']                        : FALSE;
    786         $arguments['colors']                             = isset($arguments['colors'])                             ? $arguments['colors']                             : FALSE;
    787         $arguments['convertErrorsToExceptions']          = isset($arguments['convertErrorsToExceptions'])          ? $arguments['convertErrorsToExceptions']          : TRUE;
    788         $arguments['convertNoticesToExceptions']         = isset($arguments['convertNoticesToExceptions'])         ? $arguments['convertNoticesToExceptions']         : TRUE;
    789         $arguments['convertWarningsToExceptions']        = isset($arguments['convertWarningsToExceptions'])        ? $arguments['convertWarningsToExceptions']        : TRUE;
    790         $arguments['excludeGroups']                      = isset($arguments['excludeGroups'])                      ? $arguments['excludeGroups']                      : array();
    791         $arguments['groups']                             = isset($arguments['groups'])                             ? $arguments['groups']                             : array();
    792         $arguments['logIncompleteSkipped']               = isset($arguments['logIncompleteSkipped'])               ? $arguments['logIncompleteSkipped']               : FALSE;
    793         $arguments['processIsolation']                   = isset($arguments['processIsolation'])                   ? $arguments['processIsolation']                   : FALSE;
    794         $arguments['repeat']                             = isset($arguments['repeat'])                             ? $arguments['repeat']                             : FALSE;
    795         $arguments['reportCharset']                      = isset($arguments['reportCharset'])                      ? $arguments['reportCharset']                      : 'UTF-8';
    796         $arguments['reportHighlight']                    = isset($arguments['reportHighlight'])                    ? $arguments['reportHighlight']                    : FALSE;
    797         $arguments['reportHighLowerBound']               = isset($arguments['reportHighLowerBound'])               ? $arguments['reportHighLowerBound']               : 70;
    798         $arguments['reportLowUpperBound']                = isset($arguments['reportLowUpperBound'])                ? $arguments['reportLowUpperBound']                : 35;
    799         $arguments['stopOnError']                        = isset($arguments['stopOnError'])                        ? $arguments['stopOnError']                        : FALSE;
    800         $arguments['stopOnFailure']                      = isset($arguments['stopOnFailure'])                      ? $arguments['stopOnFailure']                      : FALSE;
    801         $arguments['stopOnIncomplete']                   = isset($arguments['stopOnIncomplete'])                   ? $arguments['stopOnIncomplete']                   : FALSE;
    802         $arguments['stopOnSkipped']                      = isset($arguments['stopOnSkipped'])                      ? $arguments['stopOnSkipped']                      : FALSE;
    803         $arguments['timeoutForSmallTests']               = isset($arguments['timeoutForSmallTests'])               ? $arguments['timeoutForSmallTests']               : 1;
    804         $arguments['timeoutForMediumTests']              = isset($arguments['timeoutForMediumTests'])              ? $arguments['timeoutForMediumTests']              : 10;
    805         $arguments['timeoutForLargeTests']               = isset($arguments['timeoutForLargeTests'])               ? $arguments['timeoutForLargeTests']               : 60;
    806         $arguments['strict']                             = isset($arguments['strict'])                             ? $arguments['strict']                             : FALSE;
    807         $arguments['verbose']                            = isset($arguments['verbose'])                            ? $arguments['verbose']                            : FALSE;
    808 
    809         if ($arguments['filter'] !== FALSE &&
    810             preg_match('/^[a-zA-Z0-9_]/', $arguments['filter'])) {
    811             // Escape delimiters in regular expression. Do NOT use preg_quote,
    812             // to keep magic characters.
    813             $arguments['filter'] = '/' . str_replace(
    814               '/', '\\/', $arguments['filter']
    815             ) . '/';
    816         }
    817     }
    818 }