For those who want to run PHPUnit 6.x on MediaWiki (1.30+, PHP 7.1+, as done in [0]), the following changes are at least required so that we were able to pass our tests.
```lang=diff,name=MediaWikiTestCase
+use PHPUnit\Framework\TestCase as PHPUnit_Framework_TestCase;
+use PHPUnit\Framework\TestResult as PHPUnit_Framework_TestResult;
/**
* @since 1.18
*/
abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
```
```lang=diff,name=PHPUnitMaintClass
@@ -77,11 +77,15 @@ class PHPUnitMaintClass extends Maintenance {
// Hack to eliminate the need to use the Makefile (which sucks ATM)
array_splice( $_SERVER['argv'], 1, 0,
[ '--configuration', $IP . '/tests/phpunit/suite.xml' ] );
}
- $phpUnitClass = 'PHPUnit_TextUI_Command';
+ if ( class_exists( '\PHPUnit\TextUI\Command' ) ) {
+ $phpUnitClass = '\PHPUnit\TextUI\Command';
+ } else {
+ $phpUnitClass = 'PHPUnit_TextUI_Command';
+ }
if ( $this->hasOption( 'with-phpunitclass' ) ) {
$phpUnitClass = $this->getOption( 'with-phpunitclass' );
# Cleanup $args array so the option and its value do not
@@ -110,11 +114,11 @@ class PHPUnitMaintClass extends Maintenance {
self::$additionalOptions[$option] = true;
}
}
}
- if ( !class_exists( 'PHPUnit_Framework_TestCase' ) ) {
+ if ( !class_exists( 'PHPUnit_Framework_TestCase' ) && !class_exists( '\PHPUnit\Framework\TestCase' ) ) {
echo "PHPUnit not found. Please install it and other dev dependencies by
running `composer install` in MediaWiki root directory.\n";
```
[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/2713