diff options
author | Daimona Eaytoy <daimona.wiki@gmail.com> | 2023-07-13 02:01:29 +0200 |
---|---|---|
committer | Daimona Eaytoy <daimona.wiki@gmail.com> | 2023-07-13 03:21:45 +0200 |
commit | 56dd99570a74b8ef6eee0a28ce5e9953c0d8ed49 (patch) | |
tree | 5ac22c1492aa1cbcbd71dada2ece641fd5815246 /tests/phpunit/bootstrap.integration.php | |
parent | aff3ea89384eb253d2978e2730650d4d942a12ee (diff) | |
download | mediawikicore-56dd99570a74b8ef6eee0a28ce5e9953c0d8ed49.tar.gz mediawikicore-56dd99570a74b8ef6eee0a28ce5e9953c0d8ed49.zip |
phpunit: Streamline loading of Setup.php
Add utility methods to TestSetup and call them from the bootstrap file.
Also call the same method to load settings from
MediaWikiIntegrationTestCase when invoked via the unit tests entry
point. This also fixes a couple bug in the deferred setup scenario where
setLoadTestClassesAndNamespaces wasn't called, and the error handler
wasn't reset (T227900#9003435).
Make MediaWikiIntegrationTestCase not try to load settings more than
once. Trying to do so should probably be mostly harmless because of the
require_once usage, but it's also unnecessary and this change avoids any
chance of unwanted side effects.
Also use MW_INSTALL_PATH instead of $IP in bootstrap.php.
Bug: T227900
Change-Id: I7090976435e7e2d1264ee345e2670baaccf532ea
Diffstat (limited to 'tests/phpunit/bootstrap.integration.php')
-rw-r--r-- | tests/phpunit/bootstrap.integration.php | 48 |
1 files changed, 1 insertions, 47 deletions
diff --git a/tests/phpunit/bootstrap.integration.php b/tests/phpunit/bootstrap.integration.php index 575911e4c52b..610cd4e95643 100644 --- a/tests/phpunit/bootstrap.integration.php +++ b/tests/phpunit/bootstrap.integration.php @@ -7,54 +7,8 @@ * @file */ -use MediaWiki\MediaWikiServices; - -function wfPHPUnitFinalSetup() { - global $wgDBadminuser, $wgDBadminpassword; - global $wgDBuser, $wgDBpassword, $wgDBservers, $wgLBFactoryConf; - - // These are already set in suite.xml, but set them again in case they were changed in a settings file - ini_set( 'memory_limit', -1 ); - ini_set( 'max_execution_time', 0 ); - - if ( isset( $wgDBadminuser ) ) { - $wgDBuser = $wgDBadminuser; - $wgDBpassword = $wgDBadminpassword; - - if ( $wgDBservers ) { - /** - * @var array $wgDBservers - */ - foreach ( $wgDBservers as $i => $server ) { - $wgDBservers[$i]['user'] = $wgDBuser; - $wgDBservers[$i]['password'] = $wgDBpassword; - } - } - if ( isset( $wgLBFactoryConf['serverTemplate'] ) ) { - $wgLBFactoryConf['serverTemplate']['user'] = $wgDBuser; - $wgLBFactoryConf['serverTemplate']['password'] = $wgDBpassword; - } - $service = MediaWikiServices::getInstance()->peekService( 'DBLoadBalancerFactory' ); - if ( $service ) { - $service->destroy(); - } - } - - TestSetup::requireOnceInGlobalScope( __DIR__ . '/../common/TestsAutoLoader.php' ); - - TestSetup::applyInitialConfig(); - - ExtensionRegistry::getInstance()->setLoadTestClassesAndNamespaces( true ); -} - require_once __DIR__ . '/bootstrap.common.php'; -$IP = $GLOBALS['IP']; - -define( 'MW_SETUP_CALLBACK', 'wfPHPUnitFinalSetup' ); -TestSetup::requireOnceInGlobalScope( "$IP/includes/Setup.php" ); -// Deregister handler from MWExceptionHandler::installHandle so that PHPUnit's own handler -// stays in tact. Needs to happen after including Setup.php, which calls MWExceptionHandler::installHandle(). -restore_error_handler(); +TestSetup::loadSettingsFiles(); TestSetup::maybeCheckComposerLockUpToDate(); |