Merge "DatabasePostgres: Ignore "IGNORE" option to update()"
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiPHPUnitCommand.php
1 <?php
2
3 class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command {
4 private $cliArgs;
5 private $logListener;
6
7 public function __construct( $ignorableOptions, $cliArgs ) {
8 $ignore = function ( $arg ) {
9 };
10 foreach ( $ignorableOptions as $option ) {
11 $this->longOptions[$option] = $ignore;
12 }
13 $this->cliArgs = $cliArgs;
14 }
15
16 protected function handleCustomTestSuite() {
17 // Use our suite.xml
18 if ( !isset( $this->arguments['configuration'] ) ) {
19 $this->arguments['configuration'] = __DIR__ . '/suite.xml';
20 }
21
22 // Add our own listeners
23 $this->arguments['listeners'][] = new MediaWikiPHPUnitTestListener;
24 $this->logListener = new MediaWikiLoggerPHPUnitTestListener;
25 $this->arguments['listeners'][] = $this->logListener;
26
27 // Output only to stderr to avoid "Headers already sent" problems
28 $this->arguments['stderr'] = true;
29
30 // We could create a printer instance and avoid passing the
31 // listener statically, but then we have to recreate the
32 // appropriate arguments handling + defaults.
33 if ( !isset( $this->arguments['printer'] ) ) {
34 $this->arguments['printer'] = MediaWikiPHPUnitResultPrinter::class;
35 }
36 }
37
38 protected function createRunner() {
39 MediaWikiPHPUnitResultPrinter::setLogListener( $this->logListener );
40 $runner = new MediaWikiTestRunner;
41 $runner->setMwCliArgs( $this->cliArgs );
42 return $runner;
43 }
44 }