2019-08-21 13:16:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
2020-03-30 21:36:43 +00:00
|
|
|
use MediaWiki\FileBackend\LockManager\LockManagerGroupFactory;
|
2022-08-19 20:03:47 +00:00
|
|
|
use MediaWiki\MainConfigNames;
|
2019-08-21 13:16:27 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @coversDefaultClass FileBackendGroup
|
|
|
|
|
*/
|
|
|
|
|
class FileBackendGroupIntegrationTest extends MediaWikiIntegrationTestCase {
|
|
|
|
|
use FileBackendGroupTestTrait;
|
|
|
|
|
|
|
|
|
|
private static function getWikiID() {
|
2021-12-21 00:47:14 +00:00
|
|
|
return WikiMap::getCurrentWikiId();
|
2019-08-21 13:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
2021-07-22 03:11:47 +00:00
|
|
|
private function getLockManagerGroupFactory( $domain ): LockManagerGroupFactory {
|
2021-09-15 16:36:53 +00:00
|
|
|
return $this->getServiceContainer()->getLockManagerGroupFactory();
|
2019-08-21 13:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
2021-07-22 03:11:47 +00:00
|
|
|
private function newObj( array $options = [] ): FileBackendGroup {
|
2022-08-19 20:03:47 +00:00
|
|
|
$globals = [
|
|
|
|
|
MainConfigNames::DirectoryMode,
|
|
|
|
|
MainConfigNames::FileBackends,
|
|
|
|
|
MainConfigNames::ForeignFileRepos,
|
|
|
|
|
MainConfigNames::LocalFileRepo,
|
|
|
|
|
];
|
2019-08-21 13:16:27 +00:00
|
|
|
foreach ( $globals as $global ) {
|
2022-08-19 20:03:47 +00:00
|
|
|
$this->overrideConfigValue(
|
|
|
|
|
$global, $options[$global] ?? self::getDefaultOptions()[$global] );
|
2019-08-21 13:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 22:22:36 +00:00
|
|
|
$this->assertSame( [],
|
2019-08-21 13:16:27 +00:00
|
|
|
array_diff( array_keys( $options ), $globals, array_keys( $serviceMembers ) ) );
|
|
|
|
|
|
2021-09-15 16:36:53 +00:00
|
|
|
$services = $this->getServiceContainer();
|
2019-08-21 13:16:27 +00:00
|
|
|
|
2021-05-03 19:22:09 +00:00
|
|
|
$obj = $services->getFileBackendGroup();
|
2019-08-13 08:52:13 +00:00
|
|
|
|
2019-08-21 13:16:27 +00:00
|
|
|
foreach ( $serviceMembers as $key => $name ) {
|
2019-08-13 08:52:13 +00:00
|
|
|
$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;
|
2019-08-29 11:10:46 +00:00
|
|
|
}
|
2019-08-21 13:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
2019-08-13 08:52:13 +00:00
|
|
|
return $obj;
|
2019-08-21 13:16:27 +00:00
|
|
|
}
|
|
|
|
|
}
|