When I try to run the CentralAuth or GlobalPreferences tests, I get e.g.:
```
$ PHPUNIT_WIKI=mw_en_testpedia php /srv/mw/core/vendor/bin/phpunit --filter CentralAuthCreateLocalTest
...
1) CentralAuthCreateLocalTest::testWithAccountThatDoesNotExist
Wikimedia\Rdbms\DBQueryError: Error 1044: Access denied for user 'mw'@'localhost' to database 'centralauth'
Function: Wikimedia\Rdbms\DatabaseMySQL::doSelectDomain
Query: USE `centralauth`
/srv/mw/core/includes/libs/rdbms/database/Database.php:1205
/srv/mw/core/includes/libs/rdbms/database/Database.php:1189
/srv/mw/core/includes/libs/rdbms/database/Database.php:1163
/srv/mw/core/includes/libs/rdbms/database/DatabaseMySQL.php:204
/srv/mw/core/includes/libs/rdbms/database/Database.php:1516
/srv/mw/core/includes/libs/rdbms/loadbalancer/LoadBalancer.php:912
/srv/mw/core/includes/libs/rdbms/loadbalancer/LoadBalancer.php:801
/srv/mw/core/includes/libs/rdbms/loadbalancer/LoadBalancer.php:793
/srv/mw/core/includes/libs/rdbms/database/DBConnRef.php:110
/srv/mw/core/includes/libs/rdbms/database/DBConnRef.php:124
/srv/mw/core/includes/libs/rdbms/database/DBConnRef.php:709
/srv/mw/core/includes/libs/rdbms/database/Database.php:2700
/srv/mw/extensions/CentralAuth/includes/User/CentralAuthUser.php:620
/srv/mw/core/includes/libs/objectcache/wancache/WANObjectCache.php:1726
/srv/mw/core/includes/libs/objectcache/wancache/WANObjectCache.php:1556
/srv/mw/extensions/CentralAuth/includes/User/CentralAuthUser.php:640
/srv/mw/extensions/CentralAuth/includes/User/CentralAuthUser.php:456
/srv/mw/extensions/CentralAuth/includes/User/CentralAuthUser.php:692
/srv/mw/extensions/CentralAuth/includes/User/CentralAuthUser.php:790
/srv/mw/extensions/CentralAuth/includes/User/CentralAuthForcedLocalCreationService.php:81
/srv/mw/extensions/CentralAuth/includes/Special/SpecialCreateLocalAccount.php:87
/srv/mw/extensions/CentralAuth/tests/phpunit/CentralAuthCreateLocalTest.php:44
```
There's no "centralauth" database, that is coming from the defaults, not the wiki config. Setup.php is included in a local scope in TestSetup::requireOnceInGlobalScope() and the results are later copied to the global scope. CentralAuth has a registration hook:
```php
public static function onRegistration() {
global $wgCentralAuthDatabase, $wgSessionProviders,
$wgCentralIdLookupProvider, $wgVirtualDomainsMapping;
// Note that Wikimedia Jenkins needs special handling so we skip it here.
if ( !isset( $wgVirtualDomainsMapping['virtual-centralauth'] )
&& isset( $wgCentralAuthDatabase ) && !defined( 'MW_QUIBBLE_CI' )
) {
$wgVirtualDomainsMapping['virtual-centralauth'] = [ 'db' => $wgCentralAuthDatabase ];
}
```
But this is called before Setup.php returns, and so $wgCentralAuthDatabase just has the default at this time. You can see here the hack that makes the tests pass in Quibble.
There is a hook which tries to make unit tests use the local database:
```php
public function onUnitTestsAfterDatabaseSetup( $db, $prefix ) {
global $wgCentralAuthDatabase;
$wgCentralAuthDatabase = false;
```
However, this is broken since at least 8326b0acda7deaedc864c5a9b4cf1ed492856259 since the default $wgCentralAuthDatabase was already copied into $wgVirtualDomainsMapping by this point. Also, $wgVirtualDomainsMapping was already injected into LBFactory.
CentralAuth tests should use the local database even if they are not run under Quibble.