wiki.techinc.nl/tests/phpunit/MediaWikiPHPUnitResultPrinter.php
Daimona Eaytoy 7a494d1fa4 tests: Upgrade PHPUnit from 8.5+ to 9.5+
* DeprecatedHooksTest: Don't use assertContains().
* Replace uses of deprecated asserts:
  - assertFileNotExists() -> assertFileDoesNotExist()
* Update hierarchy of MediaWikiPHPUnitResultPrinter, since ResultPrinter
  is an interface in PHPUnit 9.
* Remove temporary forward-compat methods.
* Remove directories that don't exist from tests/phpunit/suite.xml, since
  they now make PHPUnit exit:
   - tests/phpunit/skins, it used to have SideBarTest, then moved to
     tests/phpunit/includes/skins
   - tests/phpunit/documentation, it used to have ReleaseNotesTest, then
     moved to tests/phpunit/unit/documentation
* Update configuration with --migrate-configuration and reformat.
* Avoid redefining getMockBuilder() in
  ActionModuleBasedHandlerTestTrait, use a @method annotation instead.
* In RCCacheEntryFactoryTest, avoid using internal PHPUnit logic for
  HTML validation, and use native PHP methods instead. The code was
  copied from Xml::load (moved to \Xml\Loader::load in PHPUnit 9) and
  simplified for this use case.

Bug: T243600
Bug: T262076
Change-Id: I851b9158b73d0cfc315eed9d63b15c54b05895e3
2022-10-08 02:03:55 +02:00

16 lines
481 B
PHP

<?php
use PHPUnit\Framework\TestFailure;
use PHPUnit\TextUI\DefaultResultPrinter;
class MediaWikiPHPUnitResultPrinter extends DefaultResultPrinter {
/** @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" );
}
}
}