wiki.techinc.nl/tests/phpunit/MediaWikiPHPUnitResultPrinter.php
Daimona Eaytoy 86c0a64e91 Use PHPUnit hooks for augmented logs
The TestListener interface is deprecated. This replacement has the
downside of using a public static property, but there seems to be no
other way to pass extra data to the printer (BTW: the ResultPrinter
class is internal, so it'd be even better if we could avoid subclassing
it).

Bug: T243600
Change-Id: I083146b7336ac09dfd077c8e6817553738282662
2020-09-22 11:28:10 +00:00

16 lines
468 B
PHP

<?php
use PHPUnit\Framework\TestFailure;
use PHPUnit\TextUI\ResultPrinter;
class MediaWikiPHPUnitResultPrinter extends ResultPrinter {
/** @inheritDoc */
protected function printDefectTrace( TestFailure $defect ) : void {
parent::printDefectTrace( $defect );
$test = $defect->getTestName();
$log = MediaWikiLoggerPHPUnitExtension::$testsCollection[$test] ?? null;
if ( $log ) {
$this->write( "=== Logs generated by test case\n{$log}\n===\n" );
}
}
}