wiki.techinc.nl/tests/phpunit/includes/filebackend/FileBackendGroupIntegrationTest.php
ZabeMath 08c87c13a3 Hard deprecate FileBackendGroup::singleton() and ::destroySingletons()
both deprecated since 1.35.

Bug: T249025
Change-Id: I271187e8c5ad68459cfad4c0966c8c14d225512f
2021-05-04 21:03:41 +02:00

65 lines
1.9 KiB
PHP

<?php
use MediaWiki\FileBackend\LockManager\LockManagerGroupFactory;
use MediaWiki\MediaWikiServices;
/**
* @coversDefaultClass FileBackendGroup
* @covers ::singleton
* @covers ::destroySingleton
*/
class FileBackendGroupIntegrationTest extends MediaWikiIntegrationTestCase {
use FileBackendGroupTestTrait;
private static function getWikiID() {
return wfWikiID();
}
private function getLockManagerGroupFactory( $domain ) : LockManagerGroupFactory {
return MediaWikiServices::getInstance()->getLockManagerGroupFactory();
}
private function newObj( array $options = [] ) : FileBackendGroup {
$globals = [ 'DirectoryMode', 'FileBackends', 'ForeignFileRepos', 'LocalFileRepo' ];
foreach ( $globals as $global ) {
$this->setMwGlobals(
"wg$global", $options[$global] ?? self::getDefaultOptions()[$global] );
}
$serviceMembers = [
'configuredROMode' => 'ConfiguredReadOnlyMode',
'srvCache' => 'LocalServerObjectCache',
'wanCache' => 'MainWANObjectCache',
'mimeAnalyzer' => 'MimeAnalyzer',
'lmgFactory' => 'LockManagerGroupFactory',
'tmpFileFactory' => 'TempFSFileFactory',
];
foreach ( $serviceMembers as $key => $name ) {
if ( isset( $options[$key] ) ) {
$this->setService( $name, $options[$key] );
}
}
$this->assertEmpty(
array_diff( array_keys( $options ), $globals, array_keys( $serviceMembers ) ) );
$this->resetServices();
$services = MediaWikiServices::getInstance();
$services->resetServiceForTesting( 'FileBackendGroup' );
$obj = $services->getFileBackendGroup();
foreach ( $serviceMembers as $key => $name ) {
$this->$key = $services->getService( $name );
if ( $key === 'srvCache' && $this->$key instanceof EmptyBagOStuff ) {
// ServiceWiring will have created its own HashBagOStuff that we don't have a
// reference to. Set null instead.
$this->srvCache = null;
}
}
return $obj;
}
}