When a unit test fails it is possible, perhaps even likely in some cases, that some code that was run logged useful information about how that failure came to be. Help people out, tell them what happened! Change-Id: I30bbc31799a65024868678d052fec9aafacc1aff
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command {
|
|
private $cliArgs;
|
|
private $logListener;
|
|
|
|
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';
|
|
}
|
|
|
|
// Add our own listeners
|
|
$this->arguments['listeners'][] = new MediaWikiPHPUnitTestListener;
|
|
$this->logListener = new MediaWikiLoggerPHPUnitTestListener;
|
|
$this->arguments['listeners'][] = $this->logListener;
|
|
|
|
// Output only to stderr to avoid "Headers already sent" problems
|
|
$this->arguments['stderr'] = true;
|
|
|
|
// We could create a printer instance and avoid passing the
|
|
// listener statically, but then we have to recreate the
|
|
// appropriate arguments handling + defaults.
|
|
if ( !isset( $this->arguments['printer'] ) ) {
|
|
$this->arguments['printer'] = MediaWikiPHPUnitResultPrinter::class;
|
|
}
|
|
}
|
|
|
|
protected function createRunner() {
|
|
MediaWikiPHPUnitResultPrinter::setLogListener( $this->logListener );
|
|
$runner = new MediaWikiTestRunner;
|
|
$runner->setMwCliArgs( $this->cliArgs );
|
|
return $runner;
|
|
}
|
|
}
|