wiki.techinc.nl/tests/phpunit/MediaWikiPHPUnitCommand.php
Erik Bernhardson 96657099fc Report logs for each individual test failure
The initial implementation of reporting logs with test failures was
incorrect, it always reported the logs of the most recent test run.
Attach logs to the Test when a failure is reported and pull them
back out in the result printer.

Bug: T217489
Change-Id: I5aa55d6fa7a7ec03a2e71636b6b0366ea40605cb
2019-03-06 15:13:53 -08:00

40 lines
1.1 KiB
PHP

<?php
class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command {
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';
}
// Add our own listeners
$this->arguments['listeners'][] = new MediaWikiPHPUnitTestListener;
$this->arguments['listeners'][] = new MediaWikiLoggerPHPUnitTestListener;
// Output only to stderr to avoid "Headers already sent" problems
$this->arguments['stderr'] = true;
// Use a custom result printer that includes per-test logging output
// when nothing is provided.
if ( !isset( $this->arguments['printer'] ) ) {
$this->arguments['printer'] = MediaWikiPHPUnitResultPrinter::class;
}
}
protected function createRunner() {
$runner = new MediaWikiTestRunner;
$runner->setMwCliArgs( $this->cliArgs );
return $runner;
}
}