]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/PHPUnit/TextUI/TestRunner.php
Added unit tests.
[Github/sugarcrm.git] / tests / PHPUnit / TextUI / TestRunner.php
1 <?php
2 /**
3  * PHPUnit
4  *
5  * Copyright (c) 2002-2009, Sebastian Bergmann <sb@sebastian-bergmann.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  * @category   Testing
38  * @package    PHPUnit
39  * @author     Sebastian Bergmann <sb@sebastian-bergmann.de>
40  * @copyright  2002-2009 Sebastian Bergmann <sb@sebastian-bergmann.de>
41  * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
42
43  * @link       http://www.phpunit.de/
44  * @since      File available since Release 2.0.0
45  */
46
47 require_once 'PHPUnit/Framework.php';
48 require_once 'PHPUnit/Runner/BaseTestRunner.php';
49 require_once 'PHPUnit/Extensions/RepeatedTest.php';
50 require_once 'PHPUnit/Runner/StandardTestSuiteLoader.php';
51 require_once 'PHPUnit/Runner/Version.php';
52 require_once 'PHPUnit/TextUI/ResultPrinter.php';
53 require_once 'PHPUnit/Util/Configuration.php';
54 require_once 'PHPUnit/Util/PDO.php';
55 require_once 'PHPUnit/Util/Filesystem.php';
56 require_once 'PHPUnit/Util/Filter.php';
57 require_once 'PHPUnit/Util/Report.php';
58 require_once 'PHPUnit/Util/Timer.php';
59
60 PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
61
62 /**
63  * A TestRunner for the Command Line Interface (CLI)
64  * PHP SAPI Module.
65  *
66  * @category   Testing
67  * @package    PHPUnit
68  * @author     Sebastian Bergmann <sb@sebastian-bergmann.de>
69  * @copyright  2002-2009 Sebastian Bergmann <sb@sebastian-bergmann.de>
70  * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
71  * @version    Release: 3.3.17
72  * @link       http://www.phpunit.de/
73  * @since      Class available since Release 2.0.0
74  */
75 class PHPUnit_TextUI_TestRunner extends PHPUnit_Runner_BaseTestRunner
76 {
77     const SUCCESS_EXIT   = 0;
78     const FAILURE_EXIT   = 1;
79     const EXCEPTION_EXIT = 2;
80
81     /**
82      * @var    PHPUnit_Runner_TestSuiteLoader
83      */
84     protected static $loader = NULL;
85
86     /**
87      * @var    PHPUnit_TextUI_ResultPrinter
88      */
89     protected $printer = NULL;
90
91     /**
92      * @var    boolean
93      */
94     protected static $versionStringPrinted = FALSE;
95
96     /**
97      * @param  mixed $test
98      * @param  array $arguments
99      * @throws InvalidArgumentException
100      */
101     public static function run($test, array $arguments = array())
102     {
103         if ($test instanceof ReflectionClass) {
104             $test = new PHPUnit_Framework_TestSuite($test);
105         }
106
107         if ($test instanceof PHPUnit_Framework_Test) {
108             $aTestRunner = new PHPUnit_TextUI_TestRunner;
109
110             return $aTestRunner->doRun(
111               $test,
112               $arguments
113             );
114         } else {
115             throw new InvalidArgumentException(
116               'No test case or test suite found.'
117             );
118         }
119     }
120
121     /**
122      * Runs a single test and waits until the user types RETURN.
123      *
124      * @param  PHPUnit_Framework_Test $suite
125      */
126     public static function runAndWait(PHPUnit_Framework_Test $suite)
127     {
128         $aTestRunner = new PHPUnit_TextUI_TestRunner;
129
130         $aTestRunner->doRun(
131           $suite,
132           array(
133             'wait' => TRUE
134           )
135         );
136
137     }
138
139     /**
140      * @return PHPUnit_Framework_TestResult
141      */
142     protected function createTestResult()
143     {
144         return new PHPUnit_Framework_TestResult;
145     }
146
147     /**
148      * @param  PHPUnit_Framework_Test $suite
149      * @param  array                  $arguments
150      * @return PHPUnit_Framework_TestResult
151      */
152     public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
153     {
154         $this->handleConfiguration($arguments);
155
156         if (isset($arguments['bootstrap'])) {
157             PHPUnit_Util_Fileloader::load($arguments['bootstrap']);
158         }
159
160         if (is_integer($arguments['repeat'])) {
161             $suite = new PHPUnit_Extensions_RepeatedTest(
162               $suite,
163               $arguments['repeat'],
164               $arguments['filter'],
165               $arguments['groups'],
166               $arguments['excludeGroups']
167             );
168         }
169
170         $result = $this->createTestResult();
171
172         if (!$arguments['convertErrorsToExceptions']) {
173             $result->convertErrorsToExceptions(FALSE);
174         }
175
176         if (!$arguments['convertNoticesToExceptions']) {
177             PHPUnit_Framework_Error_Notice::$enabled = FALSE;
178         }
179
180         if (!$arguments['convertWarningsToExceptions']) {
181             PHPUnit_Framework_Error_Warning::$enabled = FALSE;
182         }
183
184         if ($arguments['stopOnFailure']) {
185             $result->stopOnFailure(TRUE);
186         }
187
188         if ($this->printer === NULL) {
189             if (isset($arguments['printer']) &&
190                 $arguments['printer'] instanceof PHPUnit_Util_Printer) {
191                 $this->printer = $arguments['printer'];
192             } else {
193                 $this->printer = new PHPUnit_TextUI_ResultPrinter(
194                   NULL, $arguments['verbose'], $arguments['colors'], $arguments['debug']
195                 );
196             }
197         }
198
199         if (!$this->printer instanceof PHPUnit_Util_Log_TAP) {
200             $this->printer->write(
201               PHPUnit_Runner_Version::getVersionString() . "\n\n"
202             );
203         }
204
205         foreach ($arguments['listeners'] as $listener) {
206             $result->addListener($listener);
207         }
208
209         $result->addListener($this->printer);
210
211         if (isset($arguments['storyHTMLFile'])) {
212             require_once 'PHPUnit/Extensions/Story/ResultPrinter/HTML.php';
213
214             $result->addListener(
215               new PHPUnit_Extensions_Story_ResultPrinter_HTML(
216                 $arguments['storyHTMLFile']
217               )
218             );
219         }
220
221         if (isset($arguments['storyTextFile'])) {
222             require_once 'PHPUnit/Extensions/Story/ResultPrinter/Text.php';
223
224             $result->addListener(
225               new PHPUnit_Extensions_Story_ResultPrinter_Text(
226                 $arguments['storyTextFile']
227               )
228             );
229         }
230
231         if (isset($arguments['testdoxHTMLFile'])) {
232             require_once 'PHPUnit/Util/TestDox/ResultPrinter/HTML.php';
233
234             $result->addListener(
235               new PHPUnit_Util_TestDox_ResultPrinter_HTML(
236                 $arguments['testdoxHTMLFile']
237               )
238             );
239         }
240
241         if (isset($arguments['testdoxTextFile'])) {
242             require_once 'PHPUnit/Util/TestDox/ResultPrinter/Text.php';
243
244             $result->addListener(
245               new PHPUnit_Util_TestDox_ResultPrinter_Text(
246                 $arguments['testdoxTextFile']
247               )
248             );
249         }
250
251         if (isset($arguments['graphvizLogfile'])) {
252             if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('Image/GraphViz.php')) {
253                 require_once 'PHPUnit/Util/Log/GraphViz.php';
254
255                 $result->addListener(
256                   new PHPUnit_Util_Log_GraphViz($arguments['graphvizLogfile'])
257                 );
258             }
259         }
260
261         if ((isset($arguments['coverageClover']) ||
262              isset($arguments['coverageSource']) ||
263              isset($arguments['metricsXML']) ||
264              isset($arguments['pmdXML']) ||
265              isset($arguments['reportDirectory'])) &&
266              extension_loaded('xdebug')) {
267             $result->collectCodeCoverageInformation(TRUE);
268         }
269
270         if (isset($arguments['jsonLogfile'])) {
271             require_once 'PHPUnit/Util/Log/JSON.php';
272
273             $result->addListener(
274               new PHPUnit_Util_Log_JSON($arguments['jsonLogfile'])
275             );
276         }
277
278         if (isset($arguments['tapLogfile'])) {
279             require_once 'PHPUnit/Util/Log/TAP.php';
280
281             $result->addListener(
282               new PHPUnit_Util_Log_TAP($arguments['tapLogfile'])
283             );
284         }
285
286         if (isset($arguments['xmlLogfile'])) {
287             require_once 'PHPUnit/Util/Log/XML.php';
288
289             $result->addListener(
290               new PHPUnit_Util_Log_XML(
291                 $arguments['xmlLogfile'], $arguments['logIncompleteSkipped']
292               )
293             );
294         }
295
296         if (isset($arguments['testDatabaseDSN']) &&
297             isset($arguments['testDatabaseLogRevision']) &&
298             extension_loaded('pdo')) {
299             $writeToTestDatabase = TRUE;
300         } else {
301             $writeToTestDatabase = FALSE;
302         }
303
304         if ($writeToTestDatabase) {
305             $dbh = PHPUnit_Util_PDO::factory($arguments['testDatabaseDSN']);
306
307             require_once 'PHPUnit/Util/Log/Database.php';
308
309             $dbListener = PHPUnit_Util_Log_Database::getInstance(
310               $dbh,
311               $arguments['testDatabaseLogRevision'],
312               isset($arguments['testDatabaseLogInfo']) ? $arguments['testDatabaseLogInfo'] : ''
313             );
314
315             $result->addListener($dbListener);
316             $result->collectCodeCoverageInformation(TRUE);
317         }
318
319         $suite->run(
320           $result,
321           $arguments['filter'],
322           $arguments['groups'],
323           $arguments['excludeGroups']
324         );
325
326         $result->flushListeners();
327
328         if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
329             $this->printer->printResult($result);
330         }
331
332         if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
333             if (isset($arguments['coverageClover'])) {
334                 $this->printer->write("\nWriting code coverage data to XML file, this may take a moment.");
335
336                 require_once 'PHPUnit/Util/Log/CodeCoverage/XML/Clover.php';
337
338                 $writer = new PHPUnit_Util_Log_CodeCoverage_XML_Clover(
339                   $arguments['coverageClover']
340                 );
341
342                 $writer->process($result);
343                 $this->printer->write("\n");
344             }
345
346             if (isset($arguments['coverageSource'])) {
347                 $this->printer->write("\nWriting code coverage data to XML files, this may take a moment.");
348
349                 require_once 'PHPUnit/Util/Log/CodeCoverage/XML/Source.php';
350
351                 $writer = new PHPUnit_Util_Log_CodeCoverage_XML_Source(
352                   $arguments['coverageSource']
353                 );
354
355                 $writer->process($result);
356                 $this->printer->write("\n");
357             }
358
359             if ($writeToTestDatabase) {
360                 $this->printer->write("\nStoring code coverage and software metrics data in database.\nThis may take a moment.");
361
362                 require_once 'PHPUnit/Util/Log/CodeCoverage/Database.php';
363
364                 $testDb = new PHPUnit_Util_Log_CodeCoverage_Database($dbh);
365                 $testDb->storeCodeCoverage(
366                   $result,
367                   $dbListener->getRunId(),
368                   $arguments['testDatabaseLogRevision'],
369                   $arguments['testDatabasePrefix']
370                 );
371
372                 $this->printer->write("\n");
373             }
374
375             if (isset($arguments['metricsXML'])) {
376                 $this->printer->write("\nWriting metrics report XML file, this may take a moment.");
377
378                 require_once 'PHPUnit/Util/Log/Metrics.php';
379
380                 $writer = new PHPUnit_Util_Log_Metrics(
381                   $arguments['metricsXML']
382                 );
383
384                 $writer->process($result);
385                 $this->printer->write("\n");
386             }
387
388             if (isset($arguments['pmdXML'])) {
389                 require_once 'PHPUnit/Util/Log/PMD.php';
390
391                 $writer = new PHPUnit_Util_Log_PMD(
392                   $arguments['pmdXML'], $arguments['pmd']
393                 );
394
395                 $this->printer->write("\nWriting violations report XML file, this may take a moment.");
396                 $writer->process($result);
397
398                 require_once 'PHPUnit/Util/Log/CPD.php';
399
400                 $writer = new PHPUnit_Util_Log_CPD(
401                   str_replace('.xml', '-cpd.xml', $arguments['pmdXML'])
402                 );
403
404                 $writer->process(
405                   $result, $arguments['cpdMinLines'], $arguments['cpdMinMatches']
406                 );
407
408                 $this->printer->write("\n");
409             }
410
411             if (isset($arguments['reportDirectory'])) {
412                 $this->printer->write("\nGenerating code coverage report, this may take a moment.");
413
414                 unset($suite);
415
416                 PHPUnit_Util_Report::render(
417                   $result,
418                   $arguments['reportDirectory'],
419                   $arguments['reportCharset'],
420                   $arguments['reportYUI'],
421                   $arguments['reportHighlight'],
422                   $arguments['reportLowUpperBound'],
423                   $arguments['reportHighLowerBound']
424                 );
425
426                 $this->printer->write("\n");
427             }
428         }
429
430         $this->pause($arguments['wait']);
431
432         return $result;
433     }
434
435     /**
436      * @param  boolean $wait
437      */
438     protected function pause($wait)
439     {
440         if (!$wait) {
441             return;
442         }
443
444         if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
445             $this->printer->printWaitPrompt();
446         }
447
448         fgets(STDIN);
449     }
450
451     /**
452      * @param  PHPUnit_TextUI_ResultPrinter $resultPrinter
453      */
454     public function setPrinter(PHPUnit_TextUI_ResultPrinter $resultPrinter)
455     {
456         $this->printer = $resultPrinter;
457     }
458
459     /**
460      * A test started.
461      *
462      * @param  string  $testName
463      */
464     public function testStarted($testName)
465     {
466     }
467
468     /**
469      * A test ended.
470      *
471      * @param  string  $testName
472      */
473     public function testEnded($testName)
474     {
475     }
476
477     /**
478      * A test failed.
479      *
480      * @param  integer                                 $status
481      * @param  PHPUnit_Framework_Test                 $test
482      * @param  PHPUnit_Framework_AssertionFailedError $e
483      */
484     public function testFailed($status, PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e)
485     {
486     }
487
488     /**
489      * Override to define how to handle a failed loading of
490      * a test suite.
491      *
492      * @param  string  $message
493      */
494     protected function runFailed($message)
495     {
496         self::printVersionString();
497         self::write($message);
498         exit(self::FAILURE_EXIT);
499     }
500
501     /**
502      * @param  string $buffer
503      * @since  Method available since Release 3.1.0
504      */
505     protected static function write($buffer)
506     {
507         if (PHP_SAPI != 'cli') {
508             $buffer = htmlspecialchars($buffer);
509         }
510
511         print $buffer;
512     }
513
514     /**
515      * Returns the loader to be used.
516      *
517      * @return PHPUnit_Runner_TestSuiteLoader
518      * @since  Method available since Release 2.2.0
519      */
520     public function getLoader()
521     {
522         if (self::$loader === NULL) {
523             self::$loader = new PHPUnit_Runner_StandardTestSuiteLoader;
524         }
525
526         return self::$loader;
527     }
528
529     /**
530      * Sets the loader to be used.
531      *
532      * @param PHPUnit_Runner_TestSuiteLoader $loader
533      * @since  Method available since Release 3.0.0
534      */
535     public static function setLoader(PHPUnit_Runner_TestSuiteLoader $loader)
536     {
537         self::$loader = $loader;
538     }
539
540     /**
541      */
542     public static function showError($message)
543     {
544         self::printVersionString();
545         self::write($message . "\n");
546
547         exit(self::FAILURE_EXIT);
548     }
549
550
551     /**
552      */
553     public static function printVersionString()
554     {
555         if (!self::$versionStringPrinted) {
556             self::write(PHPUnit_Runner_Version::getVersionString() . "\n\n");
557             self::$versionStringPrinted = TRUE;
558         }
559     }
560
561     /**
562      * @param  array $arguments
563      * @since  Method available since Release 3.2.1
564      */
565     protected function handleConfiguration(array &$arguments)
566     {
567         if (isset($arguments['configuration'])) {
568             $arguments['configuration'] = new PHPUnit_Util_Configuration(
569               $arguments['configuration']
570             );
571
572             $arguments['pmd'] = $arguments['configuration']->getPMDConfiguration();
573         } else {
574             $arguments['pmd'] = array();
575         }
576
577         $arguments['debug']              = isset($arguments['debug'])              ? $arguments['debug']              : FALSE;
578         $arguments['filter']             = isset($arguments['filter'])             ? $arguments['filter']             : FALSE;
579         $arguments['listeners']          = isset($arguments['listeners'])          ? $arguments['listeners']          : array();
580         $arguments['repeat']             = isset($arguments['repeat'])             ? $arguments['repeat']             : FALSE;
581         $arguments['testDatabasePrefix'] = isset($arguments['testDatabasePrefix']) ? $arguments['testDatabasePrefix'] : '';
582         $arguments['verbose']            = isset($arguments['verbose'])            ? $arguments['verbose']            : FALSE;
583         $arguments['wait']               = isset($arguments['wait'])               ? $arguments['wait']               : FALSE;
584
585         if (isset($arguments['configuration'])) {
586             $arguments['configuration']->handlePHPConfiguration();
587
588             $filterConfiguration = $arguments['configuration']->getFilterConfiguration();
589
590             PHPUnit_Util_Filter::$addUncoveredFilesFromWhitelist = $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist'];
591
592             foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) {
593                 PHPUnit_Util_Filter::addDirectoryToFilter(
594                   $dir['path'], $dir['suffix']
595                 );
596             }
597
598             foreach ($filterConfiguration['blacklist']['include']['file'] as $file) {
599                 PHPUnit_Util_Filter::addFileToFilter($file);
600             }
601
602             foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) {
603                 PHPUnit_Util_Filter::removeDirectoryFromFilter(
604                   $dir['path'], $dir['suffix']
605                 );
606             }
607
608             foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) {
609                 PHPUnit_Util_Filter::removeFileFromFilter($file);
610             }
611
612             foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
613                 PHPUnit_Util_Filter::addDirectoryToWhitelist(
614                   $dir['path'], $dir['suffix']
615                 );
616             }
617
618             foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
619                 PHPUnit_Util_Filter::addFileToWhitelist($file);
620             }
621
622             foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
623                 PHPUnit_Util_Filter::removeDirectoryFromWhitelist(
624                   $dir['path'], $dir['suffix']
625                 );
626             }
627
628             foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
629                 PHPUnit_Util_Filter::removeFileFromWhitelist($file);
630             }
631
632             $phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
633
634             if (isset($phpunitConfiguration['bootstrap']) && !isset($arguments['bootstrap'])) {
635                 $arguments['bootstrap'] = $phpunitConfiguration['bootstrap'];
636             }
637
638             if (isset($phpunitConfiguration['colors']) && !isset($arguments['colors'])) {
639                 $arguments['colors'] = $phpunitConfiguration['colors'];
640             }
641
642             if (isset($phpunitConfiguration['convertErrorsToExceptions']) && !isset($arguments['convertErrorsToExceptions'])) {
643                 $arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions'];
644             }
645
646             if (isset($phpunitConfiguration['convertNoticesToExceptions']) && !isset($arguments['convertNoticesToExceptions'])) {
647                 $arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions'];
648             }
649
650             if (isset($phpunitConfiguration['convertWarningsToExceptions']) && !isset($arguments['convertWarningsToExceptions'])) {
651                 $arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions'];
652             }
653
654             if (isset($phpunitConfiguration['stopOnFailure']) && !isset($arguments['stopOnFailure'])) {
655                 $arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
656             }
657
658             $groupConfiguration = $arguments['configuration']->getGroupConfiguration();
659
660             if (!empty($groupConfiguration['include']) && !isset($arguments['groups'])) {
661                 $arguments['groups'] = $groupConfiguration['include'];
662             }
663
664             if (!empty($groupConfiguration['exclude']) && !isset($arguments['excludeGroups'])) {
665                 $arguments['excludeGroups'] = $groupConfiguration['exclude'];
666             }
667
668             $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
669
670             if (isset($loggingConfiguration['coverage-html']) && !isset($arguments['reportDirectory'])) {
671                 if (isset($loggingConfiguration['charset']) && !isset($arguments['reportCharset'])) {
672                     $arguments['reportCharset'] = $loggingConfiguration['charset'];
673                 }
674
675                 if (isset($loggingConfiguration['yui']) && !isset($arguments['reportYUI'])) {
676                     $arguments['reportYUI'] = $loggingConfiguration['yui'];
677                 }
678
679                 if (isset($loggingConfiguration['highlight']) && !isset($arguments['reportHighlight'])) {
680                     $arguments['reportHighlight'] = $loggingConfiguration['highlight'];
681                 }
682
683                 if (isset($loggingConfiguration['lowUpperBound']) && !isset($arguments['reportLowUpperBound'])) {
684                     $arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound'];
685                 }
686
687                 if (isset($loggingConfiguration['highLowerBound']) && !isset($arguments['reportHighLowerBound'])) {
688                     $arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound'];
689                 }
690
691                 $arguments['reportDirectory'] = $loggingConfiguration['coverage-html'];
692             }
693
694             if (isset($loggingConfiguration['coverage-clover']) && !isset($arguments['coverageClover'])) {
695                 $arguments['coverageClover'] = $loggingConfiguration['coverage-clover'];
696             }
697
698             if (isset($loggingConfiguration['coverage-xml']) && !isset($arguments['coverageClover'])) {
699                 $arguments['coverageClover'] = $loggingConfiguration['coverage-xml'];
700             }
701
702             if (isset($loggingConfiguration['coverage-source']) && !isset($arguments['coverageSource'])) {
703                 $arguments['coverageSource'] = $loggingConfiguration['coverage-source'];
704             }
705
706             if (isset($loggingConfiguration['graphviz']) && !isset($arguments['graphvizLogfile'])) {
707                 $arguments['graphvizLogfile'] = $loggingConfiguration['graphviz'];
708             }
709
710             if (isset($loggingConfiguration['json']) && !isset($arguments['jsonLogfile'])) {
711                 $arguments['jsonLogfile'] = $loggingConfiguration['json'];
712             }
713
714             if (isset($loggingConfiguration['metrics-xml']) && !isset($arguments['metricsXML'])) {
715                 $arguments['metricsXML'] = $loggingConfiguration['metrics-xml'];
716             }
717
718             if (isset($loggingConfiguration['plain'])) {
719                 $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter($loggingConfiguration['plain'], TRUE);
720             }
721
722             if (isset($loggingConfiguration['pmd-xml']) && !isset($arguments['pmdXML'])) {
723                 if (isset($loggingConfiguration['cpdMinLines']) && !isset($arguments['cpdMinLines'])) {
724                     $arguments['cpdMinLines'] = $loggingConfiguration['cpdMinLines'];
725                 }
726
727                 if (isset($loggingConfiguration['cpdMinMatches']) && !isset($arguments['cpdMinMatches'])) {
728                     $arguments['cpdMinMatches'] = $loggingConfiguration['cpdMinMatches'];
729                 }
730
731                 $arguments['pmdXML'] = $loggingConfiguration['pmd-xml'];
732             }
733
734             if (isset($loggingConfiguration['tap']) && !isset($arguments['tapLogfile'])) {
735                 $arguments['tapLogfile'] = $loggingConfiguration['tap'];
736             }
737
738             if (isset($loggingConfiguration['test-xml']) && !isset($arguments['xmlLogfile'])) {
739                 $arguments['xmlLogfile'] = $loggingConfiguration['test-xml'];
740
741                 if (isset($loggingConfiguration['logIncompleteSkipped']) && !isset($arguments['logIncompleteSkipped'])) {
742                     $arguments['logIncompleteSkipped'] = $loggingConfiguration['logIncompleteSkipped'];
743                 }
744             }
745
746             if (isset($loggingConfiguration['story-html']) && !isset($arguments['storyHTMLFile'])) {
747                 $arguments['storyHTMLFile'] = $loggingConfiguration['story-html'];
748             }
749
750             if (isset($loggingConfiguration['story-text']) && !isset($arguments['storyTextFile'])) {
751                 $arguments['storsTextFile'] = $loggingConfiguration['story-text'];
752             }
753
754             if (isset($loggingConfiguration['testdox-html']) && !isset($arguments['testdoxHTMLFile'])) {
755                 $arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html'];
756             }
757
758             if (isset($loggingConfiguration['testdox-text']) && !isset($arguments['testdoxTextFile'])) {
759                 $arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text'];
760             }
761         }
762
763         $arguments['cpdMinLines']                 = isset($arguments['cpdMinLines'])                 ? $arguments['cpdMinLines']                 : 5;
764         $arguments['cpdMinMatches']               = isset($arguments['cpdMinMatches'])               ? $arguments['cpdMinMatches']               : 70;
765         $arguments['colors']                      = isset($arguments['colors'])                      ? $arguments['colors']                      : FALSE;
766         $arguments['convertErrorsToExceptions']   = isset($arguments['convertErrorsToExceptions'])   ? $arguments['convertErrorsToExceptions']   : TRUE;
767         $arguments['convertNoticesToExceptions']  = isset($arguments['convertNoticesToExceptions'])  ? $arguments['convertNoticesToExceptions']  : TRUE;
768         $arguments['convertWarningsToExceptions'] = isset($arguments['convertWarningsToExceptions']) ? $arguments['convertWarningsToExceptions'] : TRUE;
769         $arguments['excludeGroups']               = isset($arguments['excludeGroups'])               ? $arguments['excludeGroups']               : array();
770         $arguments['groups']                      = isset($arguments['groups'])                      ? $arguments['groups']                      : array();
771         $arguments['logIncompleteSkipped']        = isset($arguments['logIncompleteSkipped'])        ? $arguments['logIncompleteSkipped']        : FALSE;
772         $arguments['reportCharset']               = isset($arguments['reportCharset'])               ? $arguments['reportCharset']               : 'ISO-8859-1';
773         $arguments['reportHighlight']             = isset($arguments['reportHighlight'])             ? $arguments['reportHighlight']             : FALSE;
774         $arguments['reportHighLowerBound']        = isset($arguments['reportHighLowerBound'])        ? $arguments['reportHighLowerBound']        : 70;
775         $arguments['reportLowUpperBound']         = isset($arguments['reportLowUpperBound'])         ? $arguments['reportLowUpperBound']         : 35;
776         $arguments['reportYUI']                   = isset($arguments['reportYUI'])                   ? $arguments['reportYUI']                   : TRUE;
777         $arguments['stopOnFailure']               = isset($arguments['stopOnFailure'])               ? $arguments['stopOnFailure']               : FALSE;
778
779         if ($arguments['filter'] !== FALSE && preg_match('/^[a-zA-Z0-9_]/', $arguments['filter'])) {
780             $arguments['filter'] = '/' . $arguments['filter'] . '/';
781         }
782     }
783 }
784 ?>