]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/PHPUnit/PHPUnit/TextUI/Command.php
Release 6.2.0
[Github/sugarcrm.git] / tests / PHPUnit / PHPUnit / TextUI / Command.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 3.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 3.0.0
58  */
59 class PHPUnit_TextUI_Command
60 {
61     /**
62      * @var array
63      */
64     protected $arguments = array(
65       'listGroups'              => FALSE,
66       'loader'                  => NULL,
67       'syntaxCheck'             => FALSE,
68       'useDefaultConfiguration' => TRUE
69     );
70
71     /**
72      * @var array
73      */
74     protected $options = array();
75
76     /**
77      * @var array
78      */
79     protected $longOptions = array(
80       'colors' => NULL,
81       'bootstrap=' => NULL,
82       'configuration=' => NULL,
83       'coverage-html=' => NULL,
84       'coverage-clover=' => NULL,
85       'debug' => NULL,
86       'exclude-group=' => NULL,
87       'filter=' => NULL,
88       'group=' => NULL,
89       'help' => NULL,
90       'include-path=' => NULL,
91       'list-groups' => NULL,
92       'loader=' => NULL,
93       'log-dbus' => NULL,
94       'log-json=' => NULL,
95       'log-junit=' => NULL,
96       'log-tap=' => NULL,
97       'process-isolation' => NULL,
98       'repeat=' => NULL,
99       'skeleton-class' => NULL,
100       'skeleton-test' => NULL,
101       'stderr' => NULL,
102       'stop-on-error' => NULL,
103       'stop-on-failure' => NULL,
104       'stop-on-incomplete' => NULL,
105       'stop-on-skipped' => NULL,
106       'story' => NULL,
107       'story-html=' => NULL,
108       'story-text=' => NULL,
109       'strict' => NULL,
110       'syntax-check' => NULL,
111       'tap' => NULL,
112       'testdox' => NULL,
113       'testdox-html=' => NULL,
114       'testdox-text=' => NULL,
115       'no-configuration' => NULL,
116       'no-globals-backup' => NULL,
117       'static-backup' => NULL,
118       'verbose' => NULL,
119       'version' => NULL,
120       'wait' => NULL
121     );
122
123     /**
124      * @param boolean $exit
125      */
126     public static function main($exit = TRUE)
127     {
128         $command = new PHPUnit_TextUI_Command;
129         $command->run($_SERVER['argv'], $exit);
130     }
131
132     /**
133      * @param array   $argv
134      * @param boolean $exit
135      */
136     public function run(array $argv, $exit = TRUE)
137     {
138         $this->handleArguments($argv);
139
140         $runner = new PHPUnit_TextUI_TestRunner($this->arguments['loader']);
141
142         if (is_object($this->arguments['test']) &&
143             $this->arguments['test'] instanceof PHPUnit_Framework_Test) {
144             $suite = $this->arguments['test'];
145         } else {
146             $suite = $runner->getTest(
147               $this->arguments['test'],
148               $this->arguments['testFile'],
149               $this->arguments['syntaxCheck']
150             );
151         }
152
153         if (count($suite) == 0) {
154             $skeleton = new PHPUnit_Util_Skeleton_Test(
155               $suite->getName(),
156               $this->arguments['testFile']
157             );
158
159             $result = $skeleton->generate(TRUE);
160
161             if (!$result['incomplete']) {
162                 eval(str_replace(array('<?php', '?>'), '', $result['code']));
163                 $suite = new PHPUnit_Framework_TestSuite(
164                   $this->arguments['test'] . 'Test'
165                 );
166             }
167         }
168
169         if ($this->arguments['listGroups']) {
170             PHPUnit_TextUI_TestRunner::printVersionString();
171
172             print "Available test group(s):\n";
173
174             $groups = $suite->getGroups();
175             sort($groups);
176
177             foreach ($groups as $group) {
178                 print " - $group\n";
179             }
180
181             exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
182         }
183
184         unset($this->arguments['test']);
185         unset($this->arguments['testFile']);
186
187         try {
188             $result = $runner->doRun($suite, $this->arguments);
189         }
190
191         catch (PHPUnit_Framework_Exception $e) {
192             print $e->getMessage() . "\n";
193         }
194
195         if ($exit) {
196             if (isset($result) && $result->wasSuccessful()) {
197                 exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
198             }
199
200             else if (!isset($result) || $result->errorCount() > 0) {
201                 exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
202             }
203
204             else {
205                 exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
206             }
207         }
208     }
209
210     /**
211      * Handles the command-line arguments.
212      *
213      * A child class of PHPUnit_TextUI_Command can hook into the argument
214      * parsing by adding the switch(es) to the $longOptions array and point to a
215      * callback method that handles the switch(es) in the child class like this
216      *
217      * <code>
218      * <?php
219      * class MyCommand extends PHPUnit_TextUI_Command
220      * {
221      *     public function __construct()
222      *     {
223      *         $this->longOptions['--my-switch'] = 'myHandler';
224      *     }
225      *
226      *     // --my-switch foo -> myHandler('foo')
227      *     protected function myHandler($value)
228      *     {
229      *     }
230      * }
231      * </code>
232      *
233      * @param array $argv
234      */
235     protected function handleArguments(array $argv)
236     {
237         try {
238             $this->options = PHPUnit_Util_Getopt::getopt(
239               $argv,
240               'd:c:',
241               array_keys($this->longOptions)
242             );
243         }
244
245         catch (RuntimeException $e) {
246             PHPUnit_TextUI_TestRunner::showError($e->getMessage());
247         }
248
249         $skeletonClass = FALSE;
250         $skeletonTest  = FALSE;
251
252         foreach ($this->options[0] as $option) {
253             switch ($option[0]) {
254                 case '--colors': {
255                     $this->arguments['colors'] = TRUE;
256                 }
257                 break;
258
259                 case '--bootstrap': {
260                     $this->arguments['bootstrap'] = $option[1];
261                 }
262                 break;
263
264                 case 'c':
265                 case '--configuration': {
266                     $this->arguments['configuration'] = $option[1];
267                 }
268                 break;
269
270                 case '--coverage-clover': {
271                     if (extension_loaded('tokenizer') &&
272                         extension_loaded('xdebug')) {
273                         $this->arguments['coverageClover'] = $option[1];
274                     } else {
275                         if (!extension_loaded('tokenizer')) {
276                             $this->showMessage(
277                               'The tokenizer extension is not loaded.'
278                             );
279                         } else {
280                             $this->showMessage(
281                               'The Xdebug extension is not loaded.'
282                             );
283                         }
284                     }
285                 }
286                 break;
287
288                 case '--coverage-html': {
289                     if (extension_loaded('tokenizer') &&
290                         extension_loaded('xdebug')) {
291                         $this->arguments['reportDirectory'] = $option[1];
292                     } else {
293                         if (!extension_loaded('tokenizer')) {
294                             $this->showMessage(
295                               'The tokenizer extension is not loaded.'
296                             );
297                         } else {
298                             $this->showMessage(
299                               'The Xdebug extension is not loaded.'
300                             );
301                         }
302                     }
303                 }
304                 break;
305
306                 case 'd': {
307                     $ini = explode('=', $option[1]);
308
309                     if (isset($ini[0])) {
310                         if (isset($ini[1])) {
311                             ini_set($ini[0], $ini[1]);
312                         } else {
313                             ini_set($ini[0], TRUE);
314                         }
315                     }
316                 }
317                 break;
318
319                 case '--debug': {
320                     $this->arguments['debug'] = TRUE;
321                 }
322                 break;
323
324                 case '--help': {
325                     $this->showHelp();
326                     exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
327                 }
328                 break;
329
330                 case '--filter': {
331                     $this->arguments['filter'] = $option[1];
332                 }
333                 break;
334
335                 case '--group': {
336                     $this->arguments['groups'] = explode(',', $option[1]);
337                 }
338                 break;
339
340                 case '--exclude-group': {
341                     $this->arguments['excludeGroups'] = explode(
342                       ',', $option[1]
343                     );
344                 }
345                 break;
346
347                 case '--include-path': {
348                     $includePath = $option[1];
349                 }
350                 break;
351
352                 case '--list-groups': {
353                     $this->arguments['listGroups'] = TRUE;
354                 }
355                 break;
356
357                 case '--loader': {
358                     $this->arguments['loader'] = $option[1];
359                 }
360                 break;
361
362                 case '--log-dbus': {
363                     $this->arguments['logDbus'] = TRUE;
364                 }
365                 break;
366
367                 case '--log-json': {
368                     $this->arguments['jsonLogfile'] = $option[1];
369                 }
370                 break;
371
372                 case '--log-junit': {
373                     $this->arguments['junitLogfile'] = $option[1];
374                 }
375                 break;
376
377                 case '--log-tap': {
378                     $this->arguments['tapLogfile'] = $option[1];
379                 }
380                 break;
381
382                 case '--process-isolation': {
383                     $this->arguments['processIsolation'] = TRUE;
384                     $this->arguments['syntaxCheck']      = FALSE;
385                 }
386                 break;
387
388                 case '--repeat': {
389                     $this->arguments['repeat'] = (int)$option[1];
390                 }
391                 break;
392
393                 case '--stderr': {
394                     $this->arguments['printer'] = new PHPUnit_TextUI_ResultPrinter(
395                       'php://stderr',
396                       isset($this->arguments['verbose']) ? $this->arguments['verbose'] : FALSE
397                     );
398                 }
399                 break;
400
401                 case '--stop-on-error': {
402                     $this->arguments['stopOnError'] = TRUE;
403                 }
404                 break;
405
406                 case '--stop-on-failure': {
407                     $this->arguments['stopOnFailure'] = TRUE;
408                 }
409                 break;
410
411                 case '--stop-on-incomplete': {
412                     $this->arguments['stopOnIncomplete'] = TRUE;
413                 }
414                 break;
415
416                 case '--stop-on-skipped': {
417                     $this->arguments['stopOnSkipped'] = TRUE;
418                 }
419                 break;
420
421                 case '--skeleton-test': {
422                     $skeletonTest  = TRUE;
423                     $skeletonClass = FALSE;
424                 }
425                 break;
426
427                 case '--skeleton-class': {
428                     $skeletonClass = TRUE;
429                     $skeletonTest  = FALSE;
430                 }
431                 break;
432
433                 case '--tap': {
434                     $this->arguments['printer'] = new PHPUnit_Util_Log_TAP;
435                 }
436                 break;
437
438                 case '--story': {
439                     $this->showMessage(
440                       'The --story functionality is deprecated and ' .
441                       'will be removed in the future.',
442                       FALSE
443                     );
444
445                     $this->arguments['printer'] = new PHPUnit_Extensions_Story_ResultPrinter_Text;
446                 }
447                 break;
448
449                 case '--story-html': {
450                     $this->showMessage(
451                       'The --story-html functionality is deprecated and ' .
452                       'will be removed in the future.',
453                       FALSE
454                     );
455
456                     $this->arguments['storyHTMLFile'] = $option[1];
457                 }
458                 break;
459
460                 case '--story-text': {
461                     $this->showMessage(
462                       'The --story-text functionality is deprecated and ' .
463                       'will be removed in the future.',
464                       FALSE
465                     );
466
467                     $this->arguments['storyTextFile'] = $option[1];
468                 }
469                 break;
470
471                 case '--syntax-check': {
472                     $this->arguments['syntaxCheck'] = TRUE;
473                 }
474                 break;
475
476                 case '--testdox': {
477                     $this->arguments['printer'] = new PHPUnit_Util_TestDox_ResultPrinter_Text;
478                 }
479                 break;
480
481                 case '--testdox-html': {
482                     $this->arguments['testdoxHTMLFile'] = $option[1];
483                 }
484                 break;
485
486                 case '--testdox-text': {
487                     $this->arguments['testdoxTextFile'] = $option[1];
488                 }
489                 break;
490
491                 case '--no-configuration': {
492                     $this->arguments['useDefaultConfiguration'] = FALSE;
493                 }
494                 break;
495
496                 case '--no-globals-backup': {
497                     $this->arguments['backupGlobals'] = FALSE;
498                 }
499                 break;
500
501                 case '--static-backup': {
502                     $this->arguments['backupStaticAttributes'] = TRUE;
503                 }
504                 break;
505
506                 case '--verbose': {
507                     $this->arguments['verbose'] = TRUE;
508                 }
509                 break;
510
511                 case '--version': {
512                     PHPUnit_TextUI_TestRunner::printVersionString();
513                     exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
514                 }
515                 break;
516
517                 case '--wait': {
518                     $this->arguments['wait'] = TRUE;
519                 }
520                 break;
521
522                 case '--strict': {
523                     $this->arguments['strict'] = TRUE;
524                 }
525                 break;
526
527                 default: {
528                     $optionName = str_replace('--', '', $option[0]);
529
530                     if (isset($this->longOptions[$optionName])) {
531                         $handler = $this->longOptions[$optionName];
532                     }
533
534                     else if (isset($this->longOptions[$optionName . '='])) {
535                         $handler = $this->longOptions[$optionName . '='];
536                     }
537
538                     if (isset($handler) && is_callable(array($this, $handler))) {
539                         $this->$handler($option[1]);
540                     }
541                 }
542             }
543         }
544
545         if (isset($this->arguments['printer']) &&
546             $this->arguments['printer'] instanceof PHPUnit_Extensions_Story_ResultPrinter_Text &&
547             isset($this->arguments['processIsolation']) &&
548             $this->arguments['processIsolation']) {
549             $this->showMessage(
550               'The story result printer cannot be used in process isolation.'
551             );
552         }
553
554         $this->handleCustomTestSuite();
555
556         if (!isset($this->arguments['test'])) {
557             if (isset($this->options[1][0])) {
558                 $this->arguments['test'] = $this->options[1][0];
559             }
560
561             if (isset($this->options[1][1])) {
562                 $this->arguments['testFile'] = $this->options[1][1];
563             } else {
564                 $this->arguments['testFile'] = '';
565             }
566
567             if (isset($this->arguments['test']) && is_file($this->arguments['test'])) {
568                 $this->arguments['testFile'] = realpath($this->arguments['test']);
569                 $this->arguments['test']     = substr($this->arguments['test'], 0, strrpos($this->arguments['test'], '.'));
570             }
571         }
572
573         if (isset($includePath)) {
574             ini_set(
575               'include_path',
576               $includePath . PATH_SEPARATOR . ini_get('include_path')
577             );
578         }
579
580         if (isset($this->arguments['bootstrap'])) {
581             $this->handleBootstrap($this->arguments['bootstrap'], $this->arguments['syntaxCheck']);
582         }
583
584         if ($this->arguments['loader'] !== NULL) {
585             $this->arguments['loader'] = $this->handleLoader($this->arguments['loader']);
586         }
587
588         if (isset($this->arguments['configuration']) &&
589             is_dir($this->arguments['configuration'])) {
590             $configurationFile = $this->arguments['configuration'] .
591                                  '/phpunit.xml';
592
593             if (file_exists($configurationFile)) {
594                 $this->arguments['configuration'] = realpath(
595                   $configurationFile
596                 );
597             }
598
599             else if (file_exists($configurationFile . '.dist')) {
600                 $this->arguments['configuration'] = realpath(
601                   $configurationFile . '.dist'
602                 );
603             }
604         }
605
606         else if (!isset($this->arguments['configuration']) &&
607                  $this->arguments['useDefaultConfiguration']) {
608             if (file_exists('phpunit.xml')) {
609                 $this->arguments['configuration'] = realpath('phpunit.xml');
610             } else if (file_exists('phpunit.xml.dist')) {
611                 $this->arguments['configuration'] = realpath(
612                   'phpunit.xml.dist'
613                 );
614             }
615         }
616
617         if (isset($this->arguments['configuration'])) {
618             try {
619                 $configuration = PHPUnit_Util_Configuration::getInstance(
620                   $this->arguments['configuration']
621                 );
622             }
623
624             catch (Exception $e) {
625                 print $e->getMessage() . "\n";
626                 exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
627             }
628
629             $phpunit = $configuration->getPHPUnitConfiguration();
630
631             if (isset($phpunit['syntaxCheck'])) {
632                 $this->arguments['syntaxCheck'] = $phpunit['syntaxCheck'];
633             }
634
635             if (isset($phpunit['testSuiteLoaderClass'])) {
636                 if (isset($phpunit['testSuiteLoaderFile'])) {
637                     $file = $phpunit['testSuiteLoaderFile'];
638                 } else {
639                     $file = '';
640                 }
641
642                 $this->arguments['loader'] = $this->handleLoader(
643                   $phpunit['testSuiteLoaderClass'], $file
644                 );
645             }
646
647             $configuration->handlePHPConfiguration();
648
649             if (!isset($this->arguments['bootstrap'])) {
650                 $phpunitConfiguration = $configuration->getPHPUnitConfiguration();
651
652                 if (isset($phpunitConfiguration['bootstrap'])) {
653                     $this->handleBootstrap($phpunitConfiguration['bootstrap'], $this->arguments['syntaxCheck']);
654                 }
655             }
656
657             $browsers = $configuration->getSeleniumBrowserConfiguration();
658
659             if (!empty($browsers)) {
660                 PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers;
661             }
662
663             if (!isset($this->arguments['test'])) {
664                 $testSuite = $configuration->getTestSuiteConfiguration(
665                   $this->arguments['syntaxCheck']
666                 );
667
668                 if ($testSuite !== NULL) {
669                     $this->arguments['test'] = $testSuite;
670                 }
671             }
672         }
673
674         if (isset($this->arguments['test']) && is_string($this->arguments['test']) && substr($this->arguments['test'], -5, 5) == '.phpt') {
675             $test = new PHPUnit_Extensions_PhptTestCase($this->arguments['test']);
676
677             $this->arguments['test'] = new PHPUnit_Framework_TestSuite;
678             $this->arguments['test']->addTest($test);
679         }
680
681         if (!isset($this->arguments['test']) ||
682             (isset($this->arguments['testDatabaseLogRevision']) && !isset($this->arguments['testDatabaseDSN']))) {
683             $this->showHelp();
684             exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
685         }
686
687         if (!isset($this->arguments['syntaxCheck'])) {
688             $this->arguments['syntaxCheck'] = FALSE;
689         }
690
691         if ($skeletonClass || $skeletonTest) {
692             if (isset($this->arguments['test']) && $this->arguments['test'] !== FALSE) {
693                 PHPUnit_TextUI_TestRunner::printVersionString();
694
695                 if ($skeletonClass) {
696                     $class = 'PHPUnit_Util_Skeleton_Class';
697                 } else {
698                     $class = 'PHPUnit_Util_Skeleton_Test';
699                 }
700
701                 try {
702                     $args      = array();
703                     $reflector = new ReflectionClass($class);
704
705                     for ($i = 0; $i <= 3; $i++) {
706                         if (isset($this->options[1][$i])) {
707                             $args[] = $this->options[1][$i];
708                         }
709                     }
710
711                     $skeleton = $reflector->newInstanceArgs($args);
712                     $skeleton->write();
713                 }
714
715                 catch (Exception $e) {
716                     print $e->getMessage() . "\n";
717                     exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
718                 }
719
720                 printf(
721                   'Wrote skeleton for "%s" to "%s".' . "\n",
722                   $skeleton->getOutClassName(),
723                   $skeleton->getOutSourceFile()
724                 );
725
726                 exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
727             } else {
728                 $this->showHelp();
729                 exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
730             }
731         }
732     }
733
734     /**
735      * Handles the loading of the PHPUnit_Runner_TestSuiteLoader implementation.
736      *
737      * @param  string  $loaderClass
738      * @param  string  $loaderFile
739      */
740     protected function handleLoader($loaderClass, $loaderFile = '')
741     {
742         if (!class_exists($loaderClass, FALSE)) {
743             if ($loaderFile == '') {
744                 $loaderFile = PHPUnit_Util_Filesystem::classNameToFilename(
745                   $loaderClass
746                 );
747             }
748
749             $loaderFile = PHPUnit_Util_Filesystem::fileExistsInIncludePath(
750               $loaderFile
751             );
752
753             if ($loaderFile !== FALSE) {
754                 require $loaderFile;
755             }
756         }
757
758         if (class_exists($loaderClass, FALSE)) {
759             $class = new ReflectionClass($loaderClass);
760
761             if ($class->implementsInterface('PHPUnit_Runner_TestSuiteLoader') &&
762                 $class->isInstantiable()) {
763                 $loader = $class->newInstance();
764             }
765         }
766
767         if (!isset($loader)) {
768             PHPUnit_TextUI_TestRunner::showError(
769               sprintf(
770                 'Could not use "%s" as loader.',
771
772                 $loaderClass
773               )
774             );
775         }
776
777         return $loader;
778     }
779
780     /**
781      * Loads a bootstrap file.
782      *
783      * @param  string  $filename
784      * @param  boolean $syntaxCheck
785      */
786     protected function handleBootstrap($filename, $syntaxCheck = FALSE)
787     {
788         try {
789             PHPUnit_Util_Fileloader::checkAndLoad($filename, $syntaxCheck);
790         }
791
792         catch (RuntimeException $e) {
793             PHPUnit_TextUI_TestRunner::showError($e->getMessage());
794         }
795     }
796
797     /**
798      * Shows a message.
799      *
800      * @param string  $message
801      * @param boolean $exit
802      */
803     protected function showMessage($message, $exit = TRUE)
804     {
805         PHPUnit_TextUI_TestRunner::printVersionString();
806         print $message . "\n";
807
808         if ($exit) {
809             exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
810         } else {
811             print "\n";
812         }
813     }
814
815     /**
816      * Show the help message.
817      */
818     protected function showHelp()
819     {
820         PHPUnit_TextUI_TestRunner::printVersionString();
821
822         print <<<EOT
823 Usage: phpunit [switches] UnitTest [UnitTest.php]
824        phpunit [switches] <directory>
825
826   --log-junit <file>        Log test execution in JUnit XML format to file.
827   --log-tap <file>          Log test execution in TAP format to file.
828   --log-dbus                Log test execution to DBUS.
829   --log-json <file>         Log test execution in JSON format.
830
831   --coverage-html <dir>     Generate code coverage report in HTML format.
832   --coverage-clover <file>  Write code coverage data in Clover XML format.
833
834   --testdox-html <file>     Write agile documentation in HTML format to file.
835   --testdox-text <file>     Write agile documentation in Text format to file.
836
837   --filter <pattern>        Filter which tests to run.
838   --group ...               Only runs tests from the specified group(s).
839   --exclude-group ...       Exclude tests from the specified group(s).
840   --list-groups             List available test groups.
841
842   --loader <loader>         TestSuiteLoader implementation to use.
843   --repeat <times>          Runs the test(s) repeatedly.
844
845   --tap                     Report test execution progress in TAP format.
846   --testdox                 Report test execution progress in TestDox format.
847
848   --colors                  Use colors in output.
849   --stderr                  Write to STDERR instead of STDOUT.
850   --stop-on-error           Stop execution upon first error.
851   --stop-on-failure         Stop execution upon first error or failure.
852   --stop-on-skipped         Stop execution upon first skipped test.
853   --stop-on-incomplete      Stop execution upon first incomplete test.
854   --strict                  Mark a test as incomplete if no assertions are made.
855   --verbose                 Output more verbose information.
856   --wait                    Waits for a keystroke after each test.
857
858   --skeleton-class          Generate Unit class for UnitTest in UnitTest.php.
859   --skeleton-test           Generate UnitTest class for Unit in Unit.php.
860
861   --process-isolation       Run each test in a separate PHP process.
862   --no-globals-backup       Do not backup and restore \$GLOBALS for each test.
863   --static-backup           Backup and restore static attributes for each test.
864   --syntax-check            Try to check source files for syntax errors.
865
866   --bootstrap <file>        A "bootstrap" PHP file that is run before the tests.
867   -c|--configuration <file> Read configuration from XML file.
868   --no-configuration        Ignore default configuration file (phpunit.xml).
869   --include-path <path(s)>  Prepend PHP's include_path with given path(s).
870   -d key[=value]            Sets a php.ini value.
871
872   --help                    Prints this usage information.
873   --version                 Prints the version and exits.
874
875   --debug                   Output debugging information.
876
877 EOT;
878     }
879
880     /**
881      * Custom callback for test suite discovery.
882      */
883     protected function handleCustomTestSuite()
884     {
885     }
886 }