Fix broken running tests locally in IDE
The class PHPMaintClass is meant to be loaded when running phpunit.php which is only done when running tests with it. When running tests by using the bootstrap file only, e.g. in an IDE, this class will not be available. Relying on it in other classes will therefore break them. Moving the required parts to another outside class and add it to the test autoloader. My feeling says, that adding the PHPMaintClass to the autoloader says "NOOOO", that's why I added a new one. There also seems to be some CI builds failing because of that: https://integration.wikimedia.org/ci/hob/quibble-vendor-mysql-php72-docker/30642/console Bug: T151101 Change-Id: I33e27009657a951173694fc847973560a1ce967b
This commit is contained in:
parent
dd570fbc63
commit
d7c72bcbe5
4 changed files with 19 additions and 15 deletions
|
|
@ -53,6 +53,7 @@ $wgAutoloadClasses += [
|
|||
'EmptyResourceLoader' => "$testDir/phpunit/ResourceLoaderTestCase.php",
|
||||
'HamcrestPHPUnitIntegration' => "$testDir/phpunit/HamcrestPHPUnitIntegration.php",
|
||||
'LessFileCompilationTest' => "$testDir/phpunit/LessFileCompilationTest.php",
|
||||
'MediaWikiCliOptions' => "$testDir/phpunit/MediaWikiCliOptions.php",
|
||||
'MediaWikiCoversValidator' => "$testDir/phpunit/MediaWikiCoversValidator.php",
|
||||
'MediaWikiGroupValidator' => "$testDir/phpunit/MediaWikiGroupValidator.php",
|
||||
'MediaWikiLangTestCase' => "$testDir/phpunit/MediaWikiLangTestCase.php",
|
||||
|
|
|
|||
14
tests/phpunit/MediaWikiCliOptions.php
Normal file
14
tests/phpunit/MediaWikiCliOptions.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
final class MediaWikiCliOptions {
|
||||
/**
|
||||
* @fixme This is an awful hack.
|
||||
*/
|
||||
public static $additionalOptions = [
|
||||
'use-filebackend' => false,
|
||||
'use-bagostuff' => false,
|
||||
'use-jobqueue' => false,
|
||||
'use-normal-tables' => false,
|
||||
'reuse-db' => false,
|
||||
];
|
||||
}
|
||||
|
|
@ -1931,7 +1931,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
|
|||
* @return mixed
|
||||
*/
|
||||
public function getCliArg( $offset ) {
|
||||
return PHPUnitMaintClass::$additionalOptions[$offset] ?? null;
|
||||
return MediaWikiCliOptions::$additionalOptions[$offset] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1940,7 +1940,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
|
|||
* @param mixed $value
|
||||
*/
|
||||
public function setCliArg( $offset, $value ) {
|
||||
PHPUnitMaintClass::$additionalOptions[$offset] = $value;
|
||||
MediaWikiCliOptions::$additionalOptions[$offset] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -14,17 +14,6 @@ define( 'MW_PHPUNIT_TEST', true );
|
|||
require_once dirname( dirname( __DIR__ ) ) . "/maintenance/Maintenance.php";
|
||||
|
||||
class PHPUnitMaintClass extends Maintenance {
|
||||
/**
|
||||
* @fixme This is an awful hack.
|
||||
*/
|
||||
public static $additionalOptions = [
|
||||
'use-filebackend' => false,
|
||||
'use-bagostuff' => false,
|
||||
'use-jobqueue' => false,
|
||||
'use-normal-tables' => false,
|
||||
'reuse-db' => false,
|
||||
];
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->setAllowUnregisteredOptions( true );
|
||||
|
|
@ -78,8 +67,8 @@ class PHPUnitMaintClass extends Maintenance {
|
|||
|
||||
fwrite( STDERR, 'Using PHP ' . PHP_VERSION . "\n" );
|
||||
|
||||
foreach ( self::$additionalOptions as $option => $default ) {
|
||||
self::$additionalOptions[$option] = $this->getOption( $option );
|
||||
foreach ( MediaWikiCliOptions::$additionalOptions as $option => $default ) {
|
||||
MediaWikiCliOptions::$additionalOptions[$option] = $this->getOption( $option );
|
||||
}
|
||||
|
||||
$command = new MediaWikiPHPUnitCommand();
|
||||
|
|
|
|||
Loading…
Reference in a new issue