2018-09-03 07:02:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
2019-10-06 04:54:59 +00:00
|
|
|
use PHPUnit\TextUI\Command;
|
|
|
|
|
|
|
|
|
|
class MediaWikiPHPUnitCommand extends Command {
|
2018-09-03 07:02:44 +00:00
|
|
|
private $cliArgs;
|
|
|
|
|
|
|
|
|
|
public function __construct( $ignorableOptions, $cliArgs ) {
|
|
|
|
|
$ignore = function ( $arg ) {
|
|
|
|
|
};
|
|
|
|
|
foreach ( $ignorableOptions as $option ) {
|
|
|
|
|
$this->longOptions[$option] = $ignore;
|
|
|
|
|
}
|
|
|
|
|
$this->cliArgs = $cliArgs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function handleCustomTestSuite() {
|
|
|
|
|
// Use our suite.xml
|
|
|
|
|
if ( !isset( $this->arguments['configuration'] ) ) {
|
|
|
|
|
$this->arguments['configuration'] = __DIR__ . '/suite.xml';
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 23:28:26 +00:00
|
|
|
// Add our own listeners
|
2018-09-03 07:02:44 +00:00
|
|
|
$this->arguments['listeners'][] = new MediaWikiPHPUnitTestListener;
|
2019-03-04 21:44:39 +00:00
|
|
|
$this->arguments['listeners'][] = new MediaWikiLoggerPHPUnitTestListener;
|
2018-10-08 18:04:12 +00:00
|
|
|
|
|
|
|
|
// Output only to stderr to avoid "Headers already sent" problems
|
|
|
|
|
$this->arguments['stderr'] = true;
|
2019-01-18 23:28:26 +00:00
|
|
|
|
2019-03-04 21:44:39 +00:00
|
|
|
// Use a custom result printer that includes per-test logging output
|
|
|
|
|
// when nothing is provided.
|
2019-01-18 23:28:26 +00:00
|
|
|
if ( !isset( $this->arguments['printer'] ) ) {
|
|
|
|
|
$this->arguments['printer'] = MediaWikiPHPUnitResultPrinter::class;
|
|
|
|
|
}
|
2018-09-03 07:02:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function createRunner() {
|
|
|
|
|
$runner = new MediaWikiTestRunner;
|
|
|
|
|
$runner->setMwCliArgs( $this->cliArgs );
|
|
|
|
|
return $runner;
|
|
|
|
|
}
|
|
|
|
|
}
|